Author Topic: tutorial for best-practice hide-and-show UI elements?  (Read 1524 times)

Foj

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
tutorial for best-practice hide-and-show UI elements?
« on: June 27, 2014, 11:06:17 AM »
Hi, does anyone know of a really good (artist + limited C#) explanation of hiding and un-hiding NGUI UI elements?

I am using - probably very inefficiently - NGUITools.SetActive(true/false). It has taken me half a day to understand that I need to leave a GameObject higher up the hierarchy 'active' to be able set 'false' items back to 'true' - this is the level I am working at  :-[

Any help with writing better code will be much appreciated. Thank you.

  1. public class display : MonoBehaviour {
  2.  
  3.         public static GameObject selectNpc01Message;
  4.  
  5.         void Start(){
  6.         }
  7.                
  8.         void Update() {
  9.                 if (GetComponent<triggerNpc01>().triggerActiveNpc01 == true){
  10.                         selectNpc01Message = GameObject.Find("selectNpc01");
  11.                         NGUITools.SetActive(selectNpc01Message,true);
  12.                         if (Input.GetKeyDown("space")){
  13.                         Debug.Log("space key was pressed");
  14.                 }
  15.                 }
  16.                 else{
  17.                         selectNpc01Message = GameObject.Find("selectMessage");
  18.                         NGUITools.SetActive(selectNpc01Message,false);
  19.                         }
  20.                 }
  21. }