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:
void Update () {
if(Input.GetButtonDown("Inventory") && canInventory){
canInventory = false;
StartCoroutine(InvTimer(1));
UseInventory();
}
}
void UseInventory(){
GameObject HudPanel = GameObject.Find("HudPanel");
GameObject InventoryPanel = GameObject.Find("InventoryPanel");
if(!inInventory){
Debug.Log("inInventory");
Screen.lockCursor = false;
NGUITools.SetActive(InventoryPanel,true);
//NGUITools.SetActive(HudPanel,false);
inInventory = true;
}
else if (inInventory){
Debug.Log("not inInventory");
Screen.lockCursor = true;
NGUITools.SetActive(InventoryPanel,false);
//NGUITools.SetActive(HudPanel,true);
inInventory = false;
}
}
public IEnumerator InvTimer(float delay){
yield return new WaitForSeconds
(delay
); canInventory = true;
}
}