Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: warlord4 on October 11, 2013, 07:13:53 PM

Title: Ngui buttons
Post by: warlord4 on October 11, 2013, 07:13:53 PM
Hi! Can not understand what is not right!
I have a script with a lot of buttons and when i will press on selected button it will do something!
here is my script!

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class graphicsittings : MonoBehaviour {
  5.         private GUILogic gui;
  6.        
  7.         public GameObject btn_Options_Menu;
  8.         public GameObject btn_Back_Options;
  9.         public GameObject btn_Save_Options;
  10.        
  11.         public GameObject toggle_Low;
  12.         public GameObject toggle_Medium;
  13.         public GameObject toggle_High;
  14.        
  15.         public GameObject Panel_Menu;
  16.         public GameObject Panel_Options;
  17.        
  18.         public GameObject Clouds;
  19.         public GameObject trees_1Group;
  20.         public GameObject trees_2Group;
  21.         public GameObject Magic;
  22.        
  23.         void Awake()
  24.     {
  25.         gui = GetComponent<GUILogic>();
  26.     }
  27.        
  28.         void InitNGUI()
  29.         {
  30.         UIEventListener.Get(btn_Options_Menu).onClick += OpenOptions;
  31.                 UIEventListener.Get(btn_Back_Options).onClick += CloseOptions;
  32.                 UIEventListener.Get(btn_Save_Options).onClick += SaveOptions;
  33.                 UIEventListener.Get(toggle_Low).onClick += LowGraph;
  34.                 UIEventListener.Get(toggle_Medium).onClick += MediumGraph;
  35.                 UIEventListener.Get(toggle_High).onClick += HighGraph;
  36.                
  37.     }
  38.         void OpenOptions (GameObject btn_Options_Menu) {
  39.                 gui.StartCoroutine("FadeOut", Panel_Menu);
  40.         NGUITools.SetActive(Panel_Options, true);
  41.                 Debug.Log ("work");
  42.                
  43.     }
  44.         void CloseOptions (GameObject go){
  45.             gui.StartCoroutine("FadeOut", Panel_Options);
  46.                 NGUITools.SetActive(Panel_Menu, true);
  47.         }
  48.        
  49.         void SaveOptions (GameObject go) {
  50.                
  51.         }
  52.        
  53.         void LowGraph (GameObject go) {
  54.                
  55.         }
  56.        
  57.         void MediumGraph (GameObject go) {
  58.                
  59.         }
  60.        
  61.         void HighGraph (GameObject go) {
  62.                
  63.         }
  64. }
Title: Re: Ngui buttons
Post by: ArenMook on October 12, 2013, 09:51:28 AM
You don't call InitNGUI from anywhere, so how do you expect it to work? o_O
Title: Re: Ngui buttons
Post by: warlord4 on October 13, 2013, 12:22:52 AM
I have found my mistake! Thanks! Void Start() instead of Void InitNGUI()!