I am using unity script and already made a plugin folder and put all the stuff into it that i needed to so that is not the problem. I am not destroying anything the code I am using is
function OnCollisionStay(col : Collision) {
if(col.gameObject.tag == "End"){
grandController = false;
var panel2 : GameObject = GameObject.Find("Panel2");
NGUITools.SetActive(panel2,false);
}
}
it successfully finds panel2 but then i get an error it says"Destroying GameObjects immediately is not permitted during physics trigger/contact or animation event callbacks. You must use Destroy instead.
UnityEngine.Object:DestroyImmediate(Object)
NGUITools:DestroyImmediate(Object) (at Assets/Plugins/NGUI/Internal/NGUITools.cs:514)
UIPanel:OnDisable() (at Assets/Plugins/NGUI/UI/UIPanel.cs:700)
UnityEngine.GameObject:SetActive(Boolean)
NGUITools:SetActiveSelf(GameObject, Boolean) (at Assets/Plugins/NGUI/Internal/NGUITools.cs:669)
NGUITools:Deactivate(Transform) (at Assets/Plugins/NGUI/Internal/NGUITools.cs:601)
NGUITools:SetActive(GameObject, Boolean) (at Assets/Plugins/NGUI/Internal/NGUITools.cs:617)"
I have no clue why something in NGUI Tools called Destroy immediate is involved with what I am doing but unity doesn't seem to like it