AttachChildren() public static méthode

public static AttachChildren ( RectTransform trans, List childs ) : void
trans RectTransform
childs List
Résultat void
        /// <summary>
        /// Fit screen size base on Unity Engine architecture.
        /// </summary>
        /// <param name="xRatio"></param>
        /// <param name="yRatio"></param>
        public void FitPerfectSize(float xRatio, float yRatio)
        {
            /* Do the scale. */
            {
                List <RectTransform> childs = null;
                if (mApplyToChildren)
                {
                    // NOTE: If not the Unity define UI, we need to  dettach all
                    // the child transform before we can resize it. If we resize
                    // it without dettach all child transforms, the children
                    // transform will also be scaled/changed.
                    //
                    // 這個有點暴力解法... 不知道為什麼Unity沒有辦法
                    // 在初始化階段一次清乾淨.
                    childs = JCS_Util.ForceDetachChildren(this.mRectTransform);
                }

                Vector3 newScale = mRectTransform.localScale;

                if (IsResponsive())
                {
                    float minRatio = Mathf.Min(xRatio, yRatio);
                    newScale.x *= minRatio;
                    newScale.y *= minRatio;
                }
                else
                {
                    newScale.x *= xRatio;
                    newScale.y *= yRatio;
                }

                mRectTransform.localScale = newScale;

                if (mApplyToChildren)
                {
                    // NOTE: Reattach all the previous child.
                    JCS_Util.AttachChildren(this.mRectTransform, childs);
                }
            }

            /* Do the position. */
            {
                Vector3 newPosition = mRectTransform.localPosition;
                newPosition.x *= xRatio;
                newPosition.y *= yRatio;

                // set to the new position
                mRectTransform.localPosition = newPosition;
            }

            // Record children once to get the render correctly!
            ReorderChildren();
        }
        /* Setter & Getter */

        /* Functions */

        private void Start()
        {
            this.mRectTransform = this.GetComponent <RectTransform>();

            List <RectTransform> childs = JCS_Util.ForceDetachChildren(this.mRectTransform);

            JCS_Util.ReattachSelf(this.mRectTransform, (parent) =>
            {
                mRectTransform.localScale = Vector3.one;
                mRectTransform.sizeDelta  = new Vector2(Screen.width, Screen.height);
            });

            JCS_Util.AttachChildren(this.mRectTransform, childs);

            mRectTransform.localPosition = Vector3.zero;
        }