//--------------------------------------------------------- public void Show(GUIBase_Element element, bool state, bool recursive) { if (element is GUIBase_Pivot) { GUIBase_Pivot pivot = (GUIBase_Pivot)element; pivot.Show(state); } else { GameObject gameObject = element.gameObject; for (int idx = 0; idx < m_ObjectsToChangeVisibility.Count; ++idx) { if (m_ObjectsToChangeVisibility[idx].m_GObj == gameObject && m_ObjectsToChangeVisibility[idx].m_Visible == state && m_ObjectsToChangeVisibility[idx].m_Recursive == recursive) { m_ObjectsToChangeVisibility.RemoveAt(idx); break; } } S_ObjectToChangeVisibility obj = new S_ObjectToChangeVisibility(gameObject, state, recursive); m_ObjectsToChangeVisibility.Add(obj); } }
// MONOBEHAVIOUR INTERFACE protected void Start() { // deduce parent Transform parentTransform = transform.parent; m_Parent = parentTransform ? parentTransform.GetComponent <GUIBase_Element>() : null; // inform sub-classes that we started System.Type type = this.GetType(); System.Reflection.MethodInfo method = type.GetMethod("OnElementStart"); if (method != null) { method.Invoke(this, null); } }
public bool Relink(GUIBase_Element element) { if (element == null) { return(false); } if (m_Parent == element) { return(true); } // notify children and parents about change NotifyLayoutChanged(true, true); // store transformations for later use Transform trans = transform; Vector3 position = trans.localPosition; Vector3 scale = trans.localScale; Quaternion rotation = trans.localRotation; // change parent in scene tree trans.parent = element.transform; // get new ui parent m_Parent = element; // re-store transformations trans.localPosition = position; trans.localScale = scale; trans.localRotation = rotation; // notify new parens about change NotifyLayoutChanged(false, true); // done return(true); }