Пример #1
0
        public override void UpdateLayoutHierarchy()
        {
            if (mChildren != null)
            {
                for (int i = 0; i < mChildren.Length; i++)
                {
                    if (mChildren[i] != null)
                    {
                        mChildren[i].SetLayoutParent(null);
                    }
                }
            }

            List <UILayoutBase> children = new List <UILayoutBase>();

            for (int i = 0; i < MyTransform.childCount; i++)
            {
                UILayoutBase child = MyTransform.GetChild(i).GetComponent <UILayoutBase>();

                if (child == null)
                {
                    continue;
                }

                children.Add(child);
                child.SetLayoutParent(this);

                child.UpdateLayoutHierarchy();
            }

            mChildren = children.ToArray();
        }
Пример #2
0
        public void SetLayoutParent(UILayoutBase parent)
        {
            mParent = parent;

            if (mParent != null)
            {
                mRectTransform.pivot = Vector2.up;

                if (mRectTransform.anchorMin.y < 0.99f)
                {
                    mRectTransform.anchorMin = new Vector2(0, 1);
                    mRectTransform.anchorMax = new Vector2(1, 1);
                }
            }
        }