Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: mimmog on August 22, 2014, 12:13:09 PM

Title: What is the best way for to do....
Post by: mimmog on August 22, 2014, 12:13:09 PM
I have this situation :
1) First scene where there are some button : play, option, info etc
2) If I click on play button I must go to the worlds choice screen
3) If I click on one world button I must go to levels choice the screen
4) If I click on one level button the game must start

The question is : what is the best way for to do this with NGUI ?
a) 4 scene with 4 ui root and call Application.levelload ?
b) 1 scene with 1 ui root and 4 Panel and enable / disable every panel for change the scene
c) There is another way ?



Thank you
Title: Re: What is the best way for to do....
Post by: mimmog on August 23, 2014, 01:37:30 AM
Aren please help me, there are not video tutorial or documentation for this question.

Thank you
Title: Re: What is the best way for to do....
Post by: ArenMook on August 23, 2014, 03:21:21 AM
One scene, one root, 4 panels. Enable/disable them as needed. That's what I do for both Windward and Starlink, and what you see in the Starlink UI kit. Starlink UI kit has a window manager system that automatically handles opening/hiding of windows and stores history for easy GoBack() logic. UIWindow.Show(panel) will automatically hide the current and will open the chosen one. UIWindow.GoBack() will hide the 'panel' and go back to the previous. Handy tool. I recently re-used it in Windward almost without modifications.
Title: Re: What is the best way for to do....
Post by: mimmog on August 25, 2014, 02:41:13 AM
...Starlink UI kit has a window manager system that automatically handles opening/hiding of windows and stores history for easy GoBack() logic. UIWindow.Show(panel) will automatically hide the current and will open the chosen one. UIWindow.GoBack() will hide the 'panel' and go back to the previous. Handy tool. I recently re-used it in Windward almost without modifications.

I can ask you why you have not inserted into the editor the option for reenable the tweens ? Because now when you show an menu with tweens if I click on one button with UIPlay Tween component you can choose "Play direction : reverse" but you must also reenable the tweens via script...would be nice reverse the tweens to the original state (if they were active They must return active... )
Title: Re: What is the best way for to do....
Post by: ArenMook on August 26, 2014, 01:41:29 AM
What do you mean? UIPlayTween has an option of what to do if the target object is disabled. Enabling is one of the options.
Title: Re: What is the best way for to do....
Post by: mimmog on August 26, 2014, 02:10:50 AM
What do you mean? UIPlayTween has an option of what to do if the target object is disabled. Enabling is one of the options.

Ok but the target's tweens must be reenabled and resetted (Toggle, ToBeginning) via script...or I wrong something ?
Title: Re: What is the best way for to do....
Post by: ArenMook on August 26, 2014, 03:31:25 AM
What happens with the tween is also chosen on UIPlayTween. Resetting it to beginning is one of the options.
Title: Re: What is the best way for to do....
Post by: mimmog on August 26, 2014, 08:29:13 AM
No, I set Player Tween like this :
- Tween Target (insert gameobject menu showed)
- Include children : No (if I set yes the menu showed is not disabled after reverse)
- Trigger Condition : On Click
- Play direction : Reverse
- if target is disabled : Enable Then Play
- If already playing : Continue
- When finished : Disable After Reverse

but the tweens was disabled and not coming back to active...I must call via script Toggle o toBeginner....why ?
Title: Re: What is the best way for to do....
Post by: ArenMook on August 27, 2014, 04:00:12 AM
You chose "if already playing - continue". Once it gets to the beginning (in your case, since you chose reverse), it will stay there. You need to choose "restart if not playing".
Title: Re: What is the best way for to do....
Post by: mimmog on August 29, 2014, 04:38:40 AM
Not work...

I have an button child of MainMenu that contain "Tween Scale"

This is UI Play Tween attached to button :

- Tween Target : MainMenu
- Include children : No
- Trigger Condition : On Click
- Play direction : Reverse
- if target is disabled : Enable Then Play
- If already playing : Restart if not playing (like you said me)
- When finished : Disable After Reverse

When I click the button the MainMenu is disabled but also Tween Scale! (instead should be reenabled) Then, now with "restart if not playing", the tween reverse not work because the gameobject is disabled immediately not when the tween finish....
Title: Re: What is the best way for to do....
Post by: ArenMook on August 30, 2014, 08:56:34 AM
Does it work fine if the direction is Forward instead?
Title: Re: What is the best way for to do....
Post by: mimmog on September 01, 2014, 04:32:17 AM
Does it work fine if the direction is Forward instead?
No, it not work fine also if the direction is Forward...but it's always been like this I always had to use the script for disable the menu and the tweens....I have also created another simple project with a base menu but not work...
Title: Re: What is the best way for to do....
Post by: ArenMook on September 01, 2014, 02:15:44 PM
I tried a simple case.

1. New scene.
2. Two sprites, one with a TweenColor on it that makes the sprite red. Another sprite has a UIPlayTween on it and a collider.
3. The UIPlayTween references the object with the TweenColor on it.
4. TweenColor is turned off -- both the tween is disabled in inspector, and the game object.
5. UIPlayTween is set to play OnClick, enable if disabled, and restart if finished.
6. Now I hit Play, click on the sprite with the UIPlayTween on it. The color of the second sprite changes smoothly, then the sprite gets disabled. I click again, the sprite gets re-enabled, and the tween works as expected. I click many times, the tween does not restart while it's running.

Everything works as expected. What are you doing differently?
Title: Re: What is the best way for to do....
Post by: mimmog on September 02, 2014, 08:26:22 AM
Ok but this is the situation :

1. New scene.
2. Two sprites, one with a TweenColor on it that makes the sprite red. Another sprite has a UIPlayTween on it and a collider.
3. The UIPlayTween references the object with the TweenColor on it.
4. TweenColor is turned ON and GameObject is enabled and visible
5. UIPlayTween is set to play OnClick, Play Direction REVERSE, If target is disabled ENABLE THEN PLAY, If already playing RESTART IF NOT PLAYING and When finished DISABLE AFTER REVERSE.
6. Now I hit Play, the color of sprite changes automatically to red, click on the sprite with the UIPlayTween but the tween not reverse and the red sprite is disabled before the tween reverse start...
Title: Re: What is the best way for to do....
Post by: ArenMook on September 02, 2014, 12:32:31 PM
I may have a solution, but I will need more time to test its effects -- meaning I need to be home first. I'm currently on vacation, meaning away from my main PC.
Title: Re: What is the best way for to do....
Post by: mimmog on September 02, 2014, 02:25:35 PM
I may have a solution, but I will need more time to test its effects -- meaning I need to be home first. I'm currently on vacation, meaning away from my main PC.
Ok no problem I just wanted report you this bug. I can wait you
Title: Re: What is the best way for to do....
Post by: mimmog on September 08, 2014, 05:16:08 PM
Hi Aren ! Do you remember to verify for this bug?

Thank you
Title: Re: What is the best way for to do....
Post by: ArenMook on September 08, 2014, 10:48:01 PM
Yeah, it's fixed in the Pro version so you'll find it in the next update.
Title: Re: What is the best way for to do....
Post by: mimmog on September 08, 2014, 11:55:14 PM
Yeah, it's fixed in the Pro version so you'll find it in the next update.
Ok thank you !  When do  you release the next update?
Title: Re: What is the best way for to do....
Post by: ArenMook on September 10, 2014, 12:37:58 AM
It'll be this week, Saturday at the latest.
Title: Re: What is the best way for to do....
Post by: mimmog on September 16, 2014, 11:54:03 AM
Hi, the version 3.7.2 not solve the problem... this is the situation :

1. New scene.
2. Two sprites, one with a TweenColor on it that makes the sprite red. Another sprite has a UIPlayTween on it and a collider.
3. The UIPlayTween references the object with the TweenColor on it.
4. TweenColor is turned ON and GameObject is enabled and visible
5. UIPlayTween is set to play OnClick, Play Direction REVERSE, If target is disabled ENABLE THEN PLAY, If already playing RESTART IF NOT PLAYING and When finished DISABLE AFTER REVERSE.

Now I hit Play, the color of sprite changes automatically to red, click on the sprite with the UIPlayTween but the the red sprite is disabled before tween reverse you can see that the red sprite is disabled before the tween reverse start and before it is completed

This is the video http://youtu.be/1zN4ba2SGI4 (http://youtu.be/1zN4ba2SGI4)
Title: Re: What is the best way for to do....
Post by: ArenMook on September 17, 2014, 11:39:10 AM
You don't have 3.7.2. If you had 3.7.2, you wouldn't see "If already playing" field anymore. It's gone. "On Activation" has taken its place.
Title: Re: What is the best way for to do....
Post by: mimmog on October 01, 2014, 07:35:22 AM
Ok now is good ! but there is another problem...when I hit Play, the sprite's color change automatically to red, then when I click on the sprite with the UIPlayTween the red sprite is disabled after tween reverse (now it's good!!) but the tween after reverse must be reenabled because if I reenable the old red sprite it must repeat the forward tween because else if I must re-display the menu I must always reset all tweens via script and it's no good for the performance...

Example :
1) Click on Play
2) Sprite change color to red
3) Click on button with UIPlayTween
4) Sprite change color to original (tween reverse) and it's disabled
5) If I reenable the sprite I don't see the change color to red such as at the second  point
Title: Re: What is the best way for to do....
Post by: mimmog on October 02, 2014, 03:30:17 PM
What do you think about this problem ArenMook?  Can you solve it?
Title: Re: What is the best way for to do....
Post by: ArenMook on October 02, 2014, 11:00:42 PM
I have a hard time understanding what you mean there. Can you give me a step by step instruction on how to re-create the new issue from scratch?
Title: Re: What is the best way for to do....
Post by: mimmog on October 03, 2014, 06:27:03 AM
Ok...look this video http://youtu.be/h3L_J1Y6zl0

1) I click Play
2) Menu is showed
3) I Click "OK" button (tween reverse and Menu is disabled after revers and it's ok!)

Attached to UIRoot I have this code for to show the menu after 1 second.  :
  1. void Start () {
  2.                 Invoke("startMenuInvoke", 1);
  3.         }
  4.  
  5.         void Update(){
  6.                 if (repeat) {
  7.                         NGUITools.SetActive(Menu, true);
  8.                         repeat = false;
  9.                 }
  10.         }
  11.        
  12.         // Update is called once per frame
  13.         void startMenuInvoke () {
  14.                 NGUITools.SetActive(Menu, true);
  15.         }
  16.  
  17.         public void repeatVar(){
  18.                 repeat = true;
  19.         }
Attached to "OK button" I have this code where into OnClick method I call "r" method that change the "repeat" bool var for to restart the menu when I click OK button and the tween reverse is finished

  1.         void Start () {
  2.                 ui = GetComponent<UIPlayTween> ();
  3.                 sMenu = root.GetComponent<startMenu> ();
  4.         }
  5.  
  6.  
  7.         void OnClick(){
  8.                 EventDelegate.Set(ui.onFinished,r);
  9.         }
  10.  
  11.         void r(){
  12.                 sMenu.repeat = true;
  13.         }

If I click on OK button the tween must reverse and when finish the menu must be reenabled and tween must go forward such as when I clicked Play for the first time but it's not as...
I think that the problem is that the tween reverse but it is not resetted to the original state, I must do it via script instead I think that the tween after reverse must be automatically resetted to original state and it should be again ready for tween forward :


O
R
I
G
I
N
A


     tween forward  --->>>>
    <<<<--- tween reverse (must came back to the original state!!)

S
T
A
T
E    
Title: Re: What is the best way for to do....
Post by: ArenMook on October 04, 2014, 07:48:32 AM
Tweens aren't reset to original state after they complete. They remain in whatever state they ended in. So if you tween something from A to B, at the end it will remain in "B" state. If you want to reset them, do tween.ResetToBeginning() in a callback set to tween.onFinished.
Title: Re: What is the best way for to do....
Post by: mimmog on October 04, 2014, 07:55:21 AM
Tweens aren't reset to original state after they complete. They remain in whatever state they ended in. So if you tween something from A to B, at the end it will remain in "B" state. If you want to reset them, do tween.ResetToBeginning() in a callback set to tween.onFinished.
Yes I know it but why you not insert an option into menu editor ? so you do not necessarily have to create an script only for to do it...
Title: Re: What is the best way for to do....
Post by: ArenMook on October 04, 2014, 08:05:29 AM
Eh. You see the OnFinished section on the tween? Drag & drop the tween's game object here. Now select the ResetToBeginning function.

Done, no need to write a script. ;)
Title: Re: What is the best way for to do....
Post by: mimmog on October 04, 2014, 09:15:41 AM
Eh. You see the OnFinished section on the tween? Drag & drop the tween's game object here. Now select the ResetToBeginning function.

Done, no need to write a script. ;)

Ok! I will try ! Thank you ;-)
Title: Re: What is the best way for to do....
Post by: mimmog on October 06, 2014, 05:30:00 AM
Eh. You see the OnFinished section on the tween? Drag & drop the tween's game object here. Now select the ResetToBeginning function.

Done, no need to write a script. ;)
Hi ! I tried but not work fine because if I recall NGUITools.SetActive(Menu, true); from script, it not work because when it disable the menu after first tween reverse it disable the menu but also the tween and not reenable it also if you set ResettoBeginning
Title: Re: What is the best way for to do....
Post by: ArenMook on October 06, 2014, 10:34:32 AM
So... call it yourself then.
  1. NGUITools.SetActive(Menu, true);
  2. Menu.GetComponent<UITweener>().ResetToBeginning();
Title: Re: What is the best way for to do....
Post by: mimmog on October 06, 2014, 11:14:16 AM
So... call it yourself then.
  1. NGUITools.SetActive(Menu, true);
  2. Menu.GetComponent<UITweener>().ResetToBeginning();
Ok but I have just set ResetToBeginning from editor -> UI Play Tween --> onFinished section Notify TweenScale -> ResetToBeginning why I must use the script code ? I don't want use the script..
Title: Re: What is the best way for to do....
Post by: ArenMook on October 07, 2014, 09:58:32 AM
All tweens derive from UITweener. When you use UIPlayTween, it plays a remote tween -- in your case TweenScale -- which derives from UITweener.

You can replace <UITweener> with <TweenScale> if you like. Same thing.