Beispiel #1
0
            static public GameObject FindOrCreateUI(string name, OnNotFoundThenPopulate populate, params GameObject[] parents)
            {
                foreach (GameObject parent in parents)
                {
                    Transform child = null;
                    if (parent != null)
                    {
                        child = parent.transform.Find(name);
                    }
                    else
                    {
                        GameObject goChild = GameObject.Find(name);
                        child = goChild != null ? goChild.transform : null;
                    }


                    if (child != null)
                    {
                        return(child.gameObject);
                    }
                }

                if (parents.Length > 0)
                {
                    return(populate(name, parents[0]));
                }

                return(populate(name, null));
            }
Beispiel #2
0
 static public GameObject FindOrCreateUI(string name, GameObject parent, OnNotFoundThenPopulate populate)
 {
     return(FindOrCreateUI(name, populate, parent));
 }