Localize callback use new UnityEvent
9 years 5 months ago #1120
by yuewah
Localize callback use new UnityEvent was created by yuewah
Localize callback is using SendMessage, can it be updated to use UnityEvent (
docs.unity3d.com/Manual/UnityEvents.html
)
Please Log in or Create an account to join the conversation.
9 years 5 months ago #1122
by Frank
Are you
Give I2L
5 stars!
Are you
Please lets us know how to improve it!
Replied by Frank on topic Localize callback use new UnityEvent
Hi,
I would also like to use UnityEvents too, but the plugin supports Unity 4.5 and they were introduced in Unity 4.6.
I'm evaluating moving the minimum required version to be 4.6 so that I could simplify a bit more the setup and use some of the new features, but I'm not sure how many developers are still using the plugin in 4.5. Been monitoring the Unity Stats and every day there are less developers using pre 4.6 versions, but still is like 4%.
Nonetheless, the current implementation of the callback, works similar to the UnityEvent, it allows you to select an object and a method within its scripts.
The benefits I see of using UnityEvent, will be that it will allow you to call several functions, even if the signature doesn't match, and that there is one less class in the project
Am I missing any other advantage that you will like to get by moving into UnityEvents? Is it because of speed differences? Haven't compared performance yet on SendMessage vs UnityEvents, but if there is a substantial one, then that will be a very compelling reason to upgrade haha.
I would also like to use UnityEvents too, but the plugin supports Unity 4.5 and they were introduced in Unity 4.6.
I'm evaluating moving the minimum required version to be 4.6 so that I could simplify a bit more the setup and use some of the new features, but I'm not sure how many developers are still using the plugin in 4.5. Been monitoring the Unity Stats and every day there are less developers using pre 4.6 versions, but still is like 4%.
Nonetheless, the current implementation of the callback, works similar to the UnityEvent, it allows you to select an object and a method within its scripts.
The benefits I see of using UnityEvent, will be that it will allow you to call several functions, even if the signature doesn't match, and that there is one less class in the project

Am I missing any other advantage that you will like to get by moving into UnityEvents? Is it because of speed differences? Haven't compared performance yet on SendMessage vs UnityEvents, but if there is a substantial one, then that will be a very compelling reason to upgrade haha.
Are you

Are you

To get the betas as soon as they are ready,
check this out
Please Log in or Create an account to join the conversation.
9 years 5 months ago #1123
by yuewah
Replied by yuewah on topic Localize callback use new UnityEvent
By the way, EventCallback or UnityEvent can have inspector features, however, some developer like using code only, no target gameobject, no new function.
Term = "HELLO_WORLD"
MainTranslation = "Hello World {0}"
e.g.
var localize = this.gameObject.GetComponent<Localize>();
localize.EventOnLocalize = () => {
Localize.MainTranslation = string.Format(Localize.MainTranslation, 999 );
}
localize.SetTerm("HELLO_WORLD");
Term = "HELLO_WORLD"
MainTranslation = "Hello World {0}"
e.g.
var localize = this.gameObject.GetComponent<Localize>();
localize.EventOnLocalize = () => {
Localize.MainTranslation = string.Format(Localize.MainTranslation, 999 );
}
localize.SetTerm("HELLO_WORLD");
Please Log in or Create an account to join the conversation.
9 years 5 months ago #1124
by Frank
Are you
Give I2L
5 stars!
Are you
Please lets us know how to improve it!
Replied by Frank on topic Localize callback use new UnityEvent
Been doing some test and I like the idea of switching into UnityEvents as it has been faster on my tests and have more features (hooking anonymous functions, multiple callbacks, etc).
I have to keep backward compatibility, so over the next few releases I will try adding code to transfer the callback values from the current system into the UnityEvents.
Will let you know as soon as this is added to the beta.
Thanks for the suggestion!
Frank
I have to keep backward compatibility, so over the next few releases I will try adding code to transfer the callback values from the current system into the UnityEvents.
Will let you know as soon as this is added to the beta.
Thanks for the suggestion!
Frank
Are you

Are you

To get the betas as soon as they are ready,
check this out
Please Log in or Create an account to join the conversation.
9 years 5 months ago - 9 years 5 months ago #1126
by yuewah
Replied by yuewah on topic Localize callback use new UnityEvent
is it possible to have shortcut method that can do the following step ?
1. Add Localize Component if not exist
2. Add Localize callback (one time)
3. SetTerm
4. Passing object args for string.Format
1. Add Localize Component if not exist
2. Add Localize callback (one time)
3. SetTerm
4. Passing object args for string.Format
Last edit: 9 years 5 months ago by yuewah.
Please Log in or Create an account to join the conversation.
Time to create page: 0.233 seconds