void TryToGetReferences() { if (topControl == null) topControl = GetComponentInChildren<LayoutTopControl>(); if (panel == null) panel = gameObject.GetComponent<LayoutPanel>(); if (foldController == null) foldController = gameObject.GetComponent<LayoutFoldController>(); if (foldController != null) foldButton = foldController.foldButton; if (layoutBorderHide == null) layoutBorderHide = GetComponent<LayoutBorderHide>(); }
public void AddBordersAndSampleContent() { if (name.Contains(LayoutPanel.spacerName)) { name = "Item " + zExt.RandomString(4); } AddBordersOnly(); var fold = gameObject.AddOrGetComponent <LayoutFoldController>(); if (fold.foldButton == null) { foldButton = CreateFoldButton(); fold.foldButton = foldButton; } else { foldButton = fold.foldButton; } Fold(fold); VerticalLayoutGroup group = gameObject.AddOrGetComponent <VerticalLayoutGroup>(); group.SetChildControl(2); Fold(group); content = gameObject.AddImageChild().AddOrGetComponent <LayoutElement>(); content.minHeight = LayoutTopControl.topHeight; content.minWidth = 26; content.flexibleWidth = 0.001f; content.GetComponent <Image>().enabled = false; content.name = "CONTENT"; Fold(content); layoutBorderHide = gameObject.AddOrGetComponent <LayoutBorderHide>(); #if UNITY_EDITOR Selection.activeObject = content; #endif Fold(GetComponent <RectTransform>()); TryToGetReferences(); var panel = gameObject.AddOrGetComponent <LayoutPanel>(); if (panel.resizableElement == null) { panel.resizableElement = content; } }
public void AddBordersOnly() { //top layoutBorderHide = gameObject.AddOrGetComponent<LayoutBorderHide>(); // layoutBorderHide = gameObject.GetComponent<LayoutBorderHide>(); // if (layoutBorderHide == null) // { // layoutBorderHide = gameObject.AddComponent<LayoutBorderHide>(); // #if UNITY_EDITOR // Undo.RegisterCreatedObjectUndo(layoutBorderHide, "content"); // #endif // } layoutBorderHide.borderColor = layoutBorderHide.borderColor.Randomize(01f, 1f, 0.2f); layoutBorderHide.borderHideMode = borderHideMode; // borders int count = System.Enum.GetNames(typeof(Side)).Length; for (int i = count - 1; i >= 0; i--) { var thisChild = gameObject.AddImageChild(); thisChild.transform.SetAsFirstSibling(); var d = thisChild.gameObject.AddOrGetComponent<LayoutBorderDragger>(); d.bordersPlacedInside=bordersPlacedInside; if (borderOverScan > 0) HandleTextRaycastCatchers(thisChild.gameObject); d.side = (Side)i; #if UNITY_EDITOR Undo.RegisterCreatedObjectUndo(thisChild.gameObject, "borders"); #endif } }
void ManageVisibility() { LayoutBorderHide bh = transform.parent.gameObject.AddOrGetComponent <LayoutBorderHide>(); UnityEditor.Selection.activeGameObject = bh.gameObject; }