public static Gui3D GetNearestGui3D(GameObject obj) { Gui3D Gui = obj.transform.root.GetComponent <Gui3D>(); if (Gui == null) { Gui = obj.transform.root.GetComponentInChildren <Gui3D>(); } if (Gui == null) { Debug.LogWarning("Gui3D not a parent of " + obj.transform.gameObject.name); GameObject.Find("Gui3D").GetComponent <Gui3D>(); } if (Gui == null) { Debug.LogError("Could not find a Gui3D"); } return(Gui); }
/// <summary> /// Gets the Gui3D containing this object. /// </summary> /// <returns> /// The Gui3D object. /// </returns> public Gui3D GetGui3D() { Gui3D Gui = transform.root.GetComponent <Gui3D>(); if (Gui == null) { Gui = transform.root.GetComponentInChildren <Gui3D>(); } if (Gui == null) { Debug.LogWarning("Gui3D not a parent of " + transform.gameObject.name); GameObject.Find("Gui3D").GetComponent <Gui3D>(); } if (Gui == null) { Debug.LogError("Could not find a Gui3D"); } // TODO: Allow multiple Gui3Ds by traversing parents? return(Gui); }