- Home /
NGUI panel wont hide
I have a script that tries to hide a panel when a button is clicked.
using UnityEngine;
using System.Collections;
public class HideTopPanel : MonoBehaviour {
public enum Trigger
{
OnClick,
}
public GameObject uiObject;
public Trigger trigger = Trigger.OnClick;
void Start () {
// assign GameObject
uiObject = GameObject.Find("PanelTop");
// uiObject.SetActiveRecursively(true);
}
void OnClick() {
if (enabled && trigger == Trigger.OnClick) {
//disable viewing the object using SetActiveRecursively()
//uiObject.SetActiveRecursively(false);
// OR
//NGUITools.SetActive(uiObject, false);
// OR
//NGUITools.SetActive(GameObject.Find("PanelTop") as GameObject, false);
// OR
// uiObject.renderer.enabled = false;
}
}
}
ive commented out all my attempts to hide the panel so you can still see all the ones i've tried. They all do the same thing which is grey out the panel and it's children in the hierarchy pane, but nothing changes visually in game. I have the latest Unity and NGUI installed on my computer.
Is there anything I am missing? Any help to visually hide the entire panel would be much appreciated.
$$anonymous$$ight be a good idea to post the NGUI forum. The developer is very responsive.
Answer by mindlube · Jul 24, 2012 at 03:40 AM
There is a NGUITools.SetActive() which was added as a workaround for SetActiveRecursively "rare odd issues" according to the ngui developer! maybe try that, or as suggested, ngui forums FTW :)
Answer by Russel · Jul 30, 2012 at 03:15 PM
GetComponent could help you ;)
UIPanel uiObject = GameObject.Find ("PanelTop").GetComponent (); uiObject.gameObject.SetActiveRecursively(false);
Got error "Cannot implicitly convert type `UnityEngine.GameObject' to `UIPanel'"
i can give false option like below code
GameObject panel1 = GameObject.Find("firstPanel");
NGUITools.SetActive(panel1,false);
After taht i cant able to make true.
Sorry, That should work.
UIPanel uiObject = GameObject.Find ("PanelTop").GetComponent < UIPanel > (); uiObject.gameObject.SetActiveRecursively(false);
In a own new script for example, which will be attached to any GameObject.