Is there an alternative way to write this function?
private void SetUIElement(string element, bool state)
{
if (!canvas.transform.Find(element).gameObject)
return;
canvas.transform.Find(element).gameObject.SetActive(state);
}
A simple function I wrote to disable a UI panel. You give it the panel name and a new state. But it's doing two Transform.Find actions, just wondered if there was a more efficient way?
Posted Apr 26, 2017, 5:50 PM UTC
19