Author Topic: Object Reference Not Set As Instance error from ngui code  (Read 2443 times)

Drados

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Object Reference Not Set As Instance error from ngui code
« 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.                 }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Object Reference Not Set As Instance error from ngui code
« Reply #1 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.