protected override void Awake() { if (_layoutGroup != null) { _layoutTransform = _layoutGroup.GetComponent <RectTransform>(); } }
public LayoutData(HorizontalOrVerticalLayoutGroup layoutGroup) { if (layoutGroup != null) { if (layoutGroup.GetComponent <VerticalLayoutGroup>() != null) { LayoutType = UILayout.Vertical; } if (layoutGroup.GetComponent <HorizontalLayoutGroup>() != null) { LayoutType = UILayout.Horizontal; } spacing = layoutGroup.spacing; padding = layoutGroup.padding; childAlignment = layoutGroup.childAlignment; childForceExpandHeight = layoutGroup.childForceExpandHeight; childForceExpandWidth = layoutGroup.childForceExpandWidth; } else { new LayoutData(); } }
void Start() { deviceResolutionChange = GetComponent <DeviceResolutionChange>(); dialogObjectRectTransform = dialogObject.GetComponent <RectTransform>(); cachedDialogObjectAnchorMax = dialogObjectRectTransform.anchorMax; buttonLayoutRectransform = buttonLayout.GetComponent <RectTransform>(); setCustomPrefabs(); deviceResolutionChange.OnOrientationChange.AddListener(onDeviceOrientationChange); deviceResolutionChange.OnResolutionChange.AddListener(onDeviceResolutionChange); }
void GUIDrawChildrens(HorizontalOrVerticalLayoutGroup layout) { var isHorizontal = layout is HorizontalLayoutGroup; Rect r; r = EditorGUILayout.BeginVertical(); GUI.Box(r, GUIContent.none); DrawLayoutHandler(layout); EditorGUILayout.BeginHorizontal(); EditorGUILayout.GetControlRect(GUILayout.Width(10)); if (!isHorizontal) { EditorGUILayout.BeginVertical(); } { var t = layout.GetComponent <RectTransform>(); if (!t) { t = layout.gameObject.AddComponent <RectTransform>(); } inHorizontalLayout = isHorizontal; for (int i = 0; i < t.childCount; i++) { GUIDraw(t.GetChild(i).gameObject); } } EditorGUILayout.Space(); if (!isHorizontal) { EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
private IEnumerator showAnimationRoutine() { dialogObject.transform.localScale = new Vector2(0, 0); dialogObject.transform.DOScale(new Vector2(1, 1), 0.15f); //Fix content scale being 0,0,0 after animation yield return(new WaitForSeconds(0.26f)); foreach (Transform child in contentLayout.transform) { child.localScale = new Vector3(1, 1, 1); } LayoutRebuilder.ForceRebuildLayoutImmediate(contentLayout.GetComponent <RectTransform>()); }
/// <summary> /// Initializes a new instance of the <see cref="UIWidgets.StandardLayoutBridge"/> class. /// </summary> /// <param name="layout">Layout.</param> /// <param name="defaultItem">Default item.</param> /// <param name="updateContentSizeFitter">Update ContentSizeFitter on direction change.</param> public StandardLayoutBridge(HorizontalOrVerticalLayoutGroup layout, RectTransform defaultItem, bool updateContentSizeFitter = true) { Utilites.UpdateLayout(layout); Layout = layout; DefaultItem = defaultItem; UpdateContentSizeFitter = updateContentSizeFitter; isHorizontal = layout is HorizontalLayoutGroup; var firstFillerGO = new GameObject("FirstFiller"); var firstFillerTransform = firstFillerGO.transform as RectTransform; if (firstFillerTransform == null) { firstFillerTransform = firstFillerGO.AddComponent <RectTransform>(); } firstFillerTransform.SetParent(Layout.transform, false); firstFillerTransform.localScale = Vector3.one; FirstFiller = firstFillerGO.AddComponent <LayoutElement>(); var lastFillerGO = new GameObject("LastFiller"); var lastFillerTransform = lastFillerGO.transform as RectTransform; if (lastFillerTransform == null) { lastFillerTransform = lastFillerGO.AddComponent <RectTransform>(); } lastFillerTransform.SetParent(Layout.transform, false); lastFillerTransform.localScale = Vector3.one; LastFiller = lastFillerGO.AddComponent <LayoutElement>(); var size = GetItemSize(); if (IsHorizontal) { firstFillerTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.y); lastFillerTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.y); } else { firstFillerTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x); lastFillerTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x); } fitter = Layout.GetComponent <ContentSizeFitter>(); }