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.

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 :slight_smile:

GetComponent could help you :wink:

UIPanel uiObject = GameObject.Find (“PanelTop”).GetComponent ();
uiObject.gameObject.SetActiveRecursively(false);