Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Drados on July 20, 2014, 12:05:50 AM

Title: Object Reference Not Set As Instance error from ngui code
Post by: Drados on July 20, 2014, 12:05:50 AM
hey all, just made an account to ask this. im using unity with the free version of ngui and im still quite new to it. my code gives this console error:
"NullReferenceException: Object reference not set to an instance of an object
NGUITools.SetActive (UnityEngine.GameObject go, Boolean state) (at Assets/NGUI/Scripts/Internal/NGUITools.cs:613)
CharacterControler.UseInventory () (at Assets/Script/CharacterControler.cs:288)
CharacterControler.Update () (at Assets/Script/CharacterControler.cs:51)"

is this a ngui issue or has my code gone wrong? my code is here if you need it:
  1.                
  2. void Update () {
  3. if(Input.GetButtonDown("Inventory") && canInventory){
  4.                         canInventory = false;
  5.                         StartCoroutine(InvTimer(1));
  6.                         UseInventory();
  7. }
  8. }
  9.         void UseInventory(){
  10.                 GameObject HudPanel = GameObject.Find("HudPanel");
  11.                 GameObject InventoryPanel = GameObject.Find("InventoryPanel");
  12.                 if(!inInventory){
  13.                         Debug.Log("inInventory");
  14.                         Screen.lockCursor = false;
  15.                         NGUITools.SetActive(InventoryPanel,true);
  16.                         //NGUITools.SetActive(HudPanel,false);
  17.                         inInventory = true;
  18.                 }
  19.                 else if (inInventory){
  20.                         Debug.Log("not inInventory");
  21.                         Screen.lockCursor = true;
  22.                         NGUITools.SetActive(InventoryPanel,false);
  23.                         //NGUITools.SetActive(HudPanel,true);
  24.                         inInventory = false;
  25.                 }
  26.         }
  27.         public IEnumerator InvTimer(float delay){
  28.                 yield return new WaitForSeconds(delay);
  29.                 canInventory = true;
  30.         }
  31.                 }
Title: Re: Object Reference Not Set As Instance error from ngui code
Post by: ArenMook on July 20, 2014, 06:13:48 PM
Sorry but the free version of NGUI doesn't come with any kind of support. It's just too different from the latest, nearly a year out of date.