Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: quenhoai on September 15, 2014, 04:30:53 AM

Title: Show/Hide pause button.
Post by: quenhoai on September 15, 2014, 04:30:53 AM
Hello all,

I testing with pause button and a panel. I want hide pause button after press it, then the panel apear. When i close this panel, the pause button apear again.

My script (with NGUI):
  1. public class popup : MonoBehaviour {
  2.  
  3.         public GameObject popUpWindow;
  4.        
  5.         void OnClick ()
  6.         {
  7.                 if (Time.timeScale == 0)
  8.                 {
  9.                         Time.timeScale =1;
  10.                 }
  11.                 else
  12.                 {
  13.                         Time.timeScale =0;
  14.                 }
  15.                 if (popUpWindow)
  16.                 {
  17.                         if (popUpWindow.activeSelf )
  18.                         {
  19.                                 popUpWindow.SetActive (false);
  20.                         }
  21.                         else
  22.                         {
  23.                                 popUpWindow.SetActive (true);
  24.                         }
  25.                 }
  26.         }
  27. }
Title: Re: Show/Hide pause button.
Post by: ArenMook on September 15, 2014, 04:34:46 AM
Is there a question there?
Title: Re: Show/Hide pause button.
Post by: quenhoai on September 15, 2014, 07:12:02 AM
I'm sorry, :) (there is not Edit funtion)

With my script, the pause button dont hide after i click it, and panel visible when start this scene.

How do i do to pause button hide after click and panel visible when start scene.

Thanks you very much.

Title: Re: Show/Hide pause button.
Post by: quenhoai on September 15, 2014, 09:04:58 AM
Please help me.
Title: Re: Show/Hide pause button.
Post by: quenhoai on September 15, 2014, 09:22:40 PM
code to make button appear/disappear is:

"this.gameObject.SetActive (false);"

But i can not make popup appear after press pause button. Now popup and pause button both appear/disappear. How can i do?

Thanks.
Title: Re: Show/Hide pause button.
Post by: ArenMook on September 16, 2014, 09:27:31 AM
I'm sorry, I am having a hard time understanding what you wrote. The pause button will disappear if it's a child of the game object you're disabling. You should never do "gameobject.setActive(false)" because this disables the object on which the script is running. Instead, create a script with a public property referencing a target game object, and make sure this script is not underneath the object you're disabling.
Title: Re: Show/Hide pause button.
Post by: quenhoai on September 16, 2014, 10:37:20 PM
I'm sorry, I am having a hard time understanding what you wrote. The pause button will disappear if it's a child of the game object you're disabling. You should never do "gameobject.setActive(false)" because this disables the object on which the script is running. Instead, create a script with a public property referencing a target game object, and make sure this script is not underneath the object you're disabling.

Very sorry about my English, i trying to improving. And with my goal, I'm fixed it. But i will make other follow your way, ArenMook. Thanks you very much. :))