Notify function is available with almost every single NGUI element and is immensely useful. Still, there is something that will make it much more versatile.
Right now, as far as I understand, Notify window populates the Method list strictly with public voids that contain no arguments whatsoever. Adding an argument stops the void method from appearing in the list. It would be nice if methods requiring arguments will be listed too, as they allow to simplify the code surrounding some stuff immensely.
For example, I have a complex encyclopedia style app with multiple screens containing various interfaces and 3d models on them, with animated transitions between those screens. As of right now, I have to make a transition manager script containing methods like:
- public void L1_To_L2 ()
- public void L1_To_L2_Reverse ()
- public void L2_To_L3 ()
- public void L2_To_L3_Reverse ()
- public void L3_To_L41 ()
- public void L3_To_L41_Reverse ()
- public void L3_To_L42 ()
- public void L3_To_L42_Reverse ()
- public void L3_To_L43 ()
- public void L3_To_L43_Reverse ()
- public void L3_To_L44 ()
- public void L3_To_L44_Reverse ()
- public void L41_To_L43 ()
- and so on
Each of them looking like this (or containing something additional like animation playback if I don't want to use Play Animation components on buttons):
public void L43_To_L53A1 () {
L43Equipment.gameObject.SetActive (false);
L53A1Generator.gameObject.SetActive (true);
}
One of those methods is then added into the Notify slot of a button triggering the appropriate transition (e.g. "Back" button on screen L3 runs the L2_To_L3_Reverse method). Of course, each GameObject variable has to be manually populated by the user in the scene manager component too.
As you can imagine, it's not exactly the most pleasant setup to work with. It's manageable if, like in my case, screen count is under a dozen or two, but it quickly becomes inconvenient. So, I've been looking to replace it with something more efficient. Like this:
public void LA_To_LB (GameObject LevelA, GameObject LevelB) {
StartCoroutine(LA_To_LB_IE(LevelA, LevelB)); }
IEnumerator LA_To_LB_IE(GameObject LevelA, GameObject LevelB){
LevelB.gameObject.SetActive (true);
LevelA.gameObject.animation.Play (exitAnimationName);
LevelB.gameObject.animation.Play (entryAnimationName);
yield return new WaitForSeconds
(LevelA
.gameObject.animation[exitAnimationName
].length); LevelA.gameObject.SetActive (false);
}
Then, a Notify list on a "Next Screen" button will show the LA_To_LB method, and upon selecting it, you'll see additional fields created in the Inspector window under the method name: them being two GameObject slots where current screen and target screen will be inserted into.
Or maybe (a man can dream, right?), even listing public IEnumerators in the Notify list, with the Notify method starting the coroutine by itself if one of them is selected.
So, how can that become a reality? Can the argument support be added by myself (if so, which scripts have to be modified and how?) or, perhaps, is it planned for future releases of NGUI?