FYI I wrote this and it worked for my purposes, I know it may not work for all. Look up the Unity docs on Resources.FindObjectsOfTypeAll to see some potential pitfalls.
public class Helpers : System.Object
{
public static Object Find(string name, System.Type type)
{
Object [] objs = Resources.FindObjectsOfTypeAll(type);
foreach (Object obj in objs)
{
if (obj.name == name)
{
return obj;
}
}
return null;
}
}
I use it like this:
UIPanel SelectSongsPanel = (UIPanel)Helpers.Find("Panel (Select Songs)", typeof(UIPanel));
SelectSongsPanel.gameObject.SetActiveRecursively(true);
↧