private void ProcessOneChild(RectTransform child, float angle, float radius)
        {
            Vector3 pos = new Vector3(
                Mathf.Cos(angle * Mathf.Deg2Rad),
                Mathf.Sin(angle * Mathf.Deg2Rad),
                0.0f);

            child.localPosition = pos * radius;

            DrivenTransformProperties drivenProperties =
                DrivenTransformProperties.Anchors | DrivenTransformProperties.AnchoredPosition | DrivenTransformProperties.Rotation | DrivenTransformProperties.Pivot;

            m_Tracker.Add(this, child, drivenProperties);

            child.anchorMin = center;
            child.anchorMax = center;
            child.pivot     = center;

            if (this.ChildRotate)
            {
                child.localEulerAngles = new Vector3(0, 0, angle);
            }
            else
            {
                child.localEulerAngles = Vector3.zero;
            }
        }
 /// <summary>
 ///   <para>Add a RectTransform to be driven.</para>
 /// </summary>
 /// <param name="driver">The object to drive properties.</param>
 /// <param name="rectTransform">The RectTransform to be driven.</param>
 /// <param name="drivenProperties">The properties to be driven.</param>
 public void Add(Object driver, RectTransform rectTransform, DrivenTransformProperties drivenProperties)
 {
   if (this.m_Tracked == null)
     this.m_Tracked = new List<RectTransform>();
   rectTransform.drivenByObject = driver;
   rectTransform.drivenProperties = rectTransform.drivenProperties | drivenProperties;
   if (!Application.isPlaying)
     RuntimeUndo.RecordObject((Object) rectTransform, "Driving RectTransform");
   this.m_Tracked.Add(rectTransform);
 }
 public void Add(UnityEngine.Object driver, RectTransform rectTransform, DrivenTransformProperties drivenProperties)
 {
     if (this.m_Tracked == null)
     {
         this.m_Tracked = new List<RectTransform>();
     }
     if (!Application.isPlaying)
     {
         RuntimeUndo.RecordObject(rectTransform, "Driving RectTransform");
     }
     this.m_Tracked.Add(rectTransform);
     rectTransform.drivenByObject = driver;
     rectTransform.drivenProperties |= drivenProperties;
 }
Beispiel #4
0
        private void HandleSelfFittingAlongAxis(int axis)
        {
            FitMode fitting = (axis == 0 ? horizontalFit : verticalFit);

            if (fitting == FitMode.Unconstrained)
            {
                // Keep a reference to the tracked transform, but don't control its properties:
                m_Tracker.Add(this, rectTsfm, DrivenTransformProperties.None);
                return;
            }

            DrivenTransformProperties flags = DrivenTransformProperties.ScaleX | DrivenTransformProperties.ScaleY;

            if (horizontalFit != FitMode.Unconstrained)
            {
                flags |= DrivenTransformProperties.SizeDeltaX;
            }
            if (verticalFit != FitMode.Unconstrained)
            {
                flags |= DrivenTransformProperties.SizeDeltaY;
            }
            m_Tracker.Add(this, rectTsfm, flags);

            // Set size to min or preferred size
            float newSize = 0f;

            if (fitting == FitMode.MinSize)
            {
                newSize = LayoutUtility.GetMinSize(m_Rect, axis);
                newSize = axis == 0 ? Mathf.Max(newSize, m_fixedSize.x) : Mathf.Max(newSize, m_fixedSize.y);
            }
            else
            {
                newSize = LayoutUtility.GetPreferredSize(m_Rect, axis);
            }


            Vector2 newSizeV;

            if (axis == 0)
            {
                newSizeV = new Vector2(Mathf.Max(newSize, m_fixedSize.x), m_Rect.sizeDelta.y);
            }
            else
            {
                newSizeV = new Vector2(m_Rect.sizeDelta.x, Mathf.Max(newSize, m_fixedSize.y));
            }
            m_Rect.SetSizeWithCurrentAnchors((RectTransform.Axis)axis, newSize);
            m_Rect.localScale = CalculateSizeScale(newSizeV, axis);
        }
Beispiel #5
0
 public void Add(Object driver, RectTransform rectTransform, DrivenTransformProperties drivenProperties)
 {
     if (this.m_Tracked == null)
     {
         this.m_Tracked = new List <RectTransform>();
     }
     rectTransform.drivenByObject    = driver;
     rectTransform.drivenProperties |= drivenProperties;
     if (!Application.isPlaying && DrivenRectTransformTracker.CanRecordModifications())
     {
         RuntimeUndo.RecordObject(rectTransform, "Driving RectTransform");
     }
     this.m_Tracked.Add(rectTransform);
 }
Beispiel #6
0
 public void Add(UnityEngine.Object driver, RectTransform rectTransform, DrivenTransformProperties drivenProperties)
 {
     if (this.m_Tracked == null)
     {
         this.m_Tracked = new List <RectTransform>();
     }
     if (!Application.isPlaying)
     {
         RuntimeUndo.RecordObject(rectTransform, "Driving RectTransform");
     }
     this.m_Tracked.Add(rectTransform);
     rectTransform.drivenByObject    = driver;
     rectTransform.drivenProperties |= drivenProperties;
 }
Beispiel #7
0
        void Add2Tracker(RectTransform child)
        {
            DrivenTransformProperties driven_properties = DrivenTransformProperties.None;

            if (ChildrenWidth != ChildrenSize.DoNothing)
            {
                driven_properties |= DrivenTransformProperties.SizeDeltaX;
            }
            if (ChildrenHeight != ChildrenSize.DoNothing)
            {
                driven_properties |= DrivenTransformProperties.SizeDeltaY;
            }

            propertiesTracker.Add(this, child, driven_properties);
        }
Beispiel #8
0
        protected virtual float AlignChild(RectTransform child, ref float offset)
        {
            float num  = (this.direction != AlignDirection.LeftToRight) ? ((float)(-1)) : ((float)1);
            float num2 = (this.direction != AlignDirection.LeftToRight) ? ((float)1) : ((float)0);
            DrivenTransformProperties properties = 0x502;

            this.tracker.Add(this, child, properties);
            child.set_anchorMin(new Vector2(num2, child.get_anchorMin().y));
            child.set_anchorMax(new Vector2(num2, child.get_anchorMax().y));
            this.CustomChild(child, offset);
            float num3 = child.get_rect().get_width() * Mathf.Abs(child.get_localScale().x);

            offset += num * (num3 * child.get_pivot().x);
            child.set_anchoredPosition(new Vector2(offset, child.get_anchoredPosition().y));
            offset += num * ((num3 * (1f - child.get_pivot().x)) + base.space);
            return(num3);
        }
        public void Add(Object driver, RectTransform rectTransform, DrivenTransformProperties drivenProperties)
        {
            if (m_Tracked == null)
            {
                m_Tracked = new List <RectTransform>();
            }

            if (!Application.isPlaying && CanRecordModifications() && !s_BlockUndo)
            {
                RuntimeUndo.RecordObject(rectTransform, "Driving RectTransform");
            }

            rectTransform.drivenByObject   = driver;
            rectTransform.drivenProperties = rectTransform.drivenProperties | drivenProperties;

            m_Tracked.Add(rectTransform);
        }
Beispiel #10
0
        public void Add(Object driver, RectTransform rectTransform, DrivenTransformProperties drivenProperties)
        {
            bool flag = this.m_Tracked == null;

            if (flag)
            {
                this.m_Tracked = new List <RectTransform>();
            }
            bool flag2 = !Application.isPlaying && DrivenRectTransformTracker.CanRecordModifications() && !DrivenRectTransformTracker.s_BlockUndo;

            if (flag2)
            {
                RuntimeUndo.RecordObject(rectTransform, "Driving RectTransform");
            }
            rectTransform.drivenByObject    = driver;
            rectTransform.drivenProperties |= drivenProperties;
            this.m_Tracked.Add(rectTransform);
        }
Beispiel #11
0
        void ResizeChild(RectTransform child)
        {
            DrivenTransformProperties driven_properties = DrivenTransformProperties.None;

            if (ChildrenWidth != ChildrenSize.DoNothing)
            {
                driven_properties |= DrivenTransformProperties.SizeDeltaX;
                var width = (max_width != -1) ? max_width : GetPreferredWidth(child);
                child.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
            }
            if (ChildrenHeight != ChildrenSize.DoNothing)
            {
                driven_properties |= DrivenTransformProperties.SizeDeltaY;
                var height = (max_height != -1) ? max_height : GetPreferredHeight(child);
                child.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);
            }

            propertiesTracker.Add(this, child, driven_properties);
        }
        protected override void CustomLayoutRectTransform()
        {
            DrivenTransformProperties properties = 0;

            properties |= 0x4500;
            this.tracker.Add(this, base.CachedRectTransform, properties);
            if (base.direction == UguiHorizontalAlignGroup.AlignDirection.LeftToRight)
            {
                base.CachedRectTransform.set_anchorMin(new Vector2(0f, base.CachedRectTransform.get_anchorMin().y));
                base.CachedRectTransform.set_anchorMax(new Vector2(0f, base.CachedRectTransform.get_anchorMax().y));
                base.CachedRectTransform.set_pivot(new Vector2(0f, base.CachedRectTransform.get_pivot().y));
            }
            else
            {
                base.CachedRectTransform.set_anchorMin(new Vector2(1f, base.CachedRectTransform.get_anchorMin().y));
                base.CachedRectTransform.set_anchorMax(new Vector2(1f, base.CachedRectTransform.get_anchorMax().y));
                base.CachedRectTransform.set_pivot(new Vector2(1f, base.CachedRectTransform.get_pivot().y));
            }
        }
Beispiel #13
0
        protected override void CustomLayoutRectTransform()
        {
            DrivenTransformProperties properties = 0;

            properties |= 0x8a00;
            this.tracker.Add(this, base.CachedRectTransform, properties);
            if (base.direction == UguiVerticalAlignGroup.AlignDirection.BottomToTop)
            {
                base.CachedRectTransform.set_anchorMin(new Vector2(base.CachedRectTransform.get_anchorMin().x, 0f));
                base.CachedRectTransform.set_anchorMax(new Vector2(base.CachedRectTransform.get_anchorMax().x, 0f));
                base.CachedRectTransform.set_pivot(new Vector2(base.CachedRectTransform.get_pivot().x, 0f));
            }
            else
            {
                base.CachedRectTransform.set_anchorMin(new Vector2(base.CachedRectTransform.get_anchorMin().x, 1f));
                base.CachedRectTransform.set_anchorMax(new Vector2(base.CachedRectTransform.get_anchorMax().x, 1f));
                base.CachedRectTransform.set_pivot(new Vector2(base.CachedRectTransform.get_pivot().x, 1f));
            }
        }
Beispiel #14
0
        /// <summary>
        /// Actual resize.
        /// </summary>
        public void ApplyResize()
        {
            DrivenTransformProperties driven_properties = DrivenTransformProperties.AnchoredPosition | DrivenTransformProperties.AnchoredPositionZ;

            if (ChangedWidth)
            {
                driven_properties |= DrivenTransformProperties.SizeDeltaX;
                Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, NewWidth);
            }
            if (ChangedHeight)
            {
                driven_properties |= DrivenTransformProperties.SizeDeltaY;
                Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, NewHeight);
            }

            if (ChangedWidth || ChangedHeight)
            {
                Resizer.PropertiesTracker.Add(Layout, Rect, driven_properties);
            }
        }
        protected DrivenTransformProperties GetChildPropertyDriven(int axis, bool wheelEffect)
        {
            DrivenTransformProperties driven = DrivenTransformProperties.AnchoredPosition3D | DrivenTransformProperties.Rotation;

            if (axis == 0)
            {
                driven |= DrivenTransformProperties.AnchorMinX | DrivenTransformProperties.AnchorMaxX;
            }
            else
            {
                driven |= DrivenTransformProperties.AnchorMinY | DrivenTransformProperties.AnchorMaxY;
            }

            if (wheelEffect)
            {
                driven |= DrivenTransformProperties.ScaleX | DrivenTransformProperties.ScaleY;
            }

            return(driven);
        }
Beispiel #16
0
        protected override void CustomLayoutRectTransform()
        {
            DrivenTransformProperties properties = DrivenTransformProperties.None;

            properties |= DrivenTransformProperties.AnchorMinY
                          | DrivenTransformProperties.AnchorMaxY
                          | DrivenTransformProperties.PivotY;
            tracker.Add(this, CachedRectTransform, properties);

            if (direction == AlignDirection.BottomToTop)
            {
                CachedRectTransform.anchorMin = new Vector2(CachedRectTransform.anchorMin.x, 0);
                CachedRectTransform.anchorMax = new Vector2(CachedRectTransform.anchorMax.x, 0);
                CachedRectTransform.pivot     = new Vector2(CachedRectTransform.pivot.x, 0);
            }
            else
            {
                CachedRectTransform.anchorMin = new Vector2(CachedRectTransform.anchorMin.x, 1);
                CachedRectTransform.anchorMax = new Vector2(CachedRectTransform.anchorMax.x, 1);
                CachedRectTransform.pivot     = new Vector2(CachedRectTransform.pivot.x, 1);
            }
        }
    protected override void OnValidate()
    {
        tracker.Clear();

        if (content != null && !Application.isPlaying)
        {
            DrivenTransformProperties drivenProperties =
                ((scrollDir == ScrollDirection.Vertical) ? DrivenTransformProperties.AnchoredPositionY : DrivenTransformProperties.AnchoredPositionX) |
                ((scrollDir == ScrollDirection.Vertical) ? DrivenTransformProperties.AnchorMinY : DrivenTransformProperties.AnchorMinX) |
                ((scrollDir == ScrollDirection.Vertical) ? DrivenTransformProperties.AnchorMaxY : DrivenTransformProperties.AnchorMaxX) |
                ((scrollDir == ScrollDirection.Vertical) ? DrivenTransformProperties.PivotY : DrivenTransformProperties.PivotX) |
                ((scrollDir == ScrollDirection.Vertical) ? DrivenTransformProperties.SizeDeltaY : DrivenTransformProperties.SizeDeltaX);

            tracker.Add(this, content, drivenProperties);

            SetupRectTransform(content);

            SetAnchoredPosition(content, 0);
            content.sizeDelta = new Vector2(scrollDir == ScrollDirection.Vertical ? content.sizeDelta.x : 0,
                                            scrollDir == ScrollDirection.Vertical ? 0 : content.sizeDelta.y);
        }
    }
        protected override void CustomLayoutRectTransform()
        {
            DrivenTransformProperties properties = DrivenTransformProperties.None;

            properties |= DrivenTransformProperties.AnchorMinX
                          | DrivenTransformProperties.AnchorMaxX
                          | DrivenTransformProperties.PivotX;
            tracker.Add(this, CachedRectTransform, properties);

            if (direction == AlignDirection.LeftToRight)
            {
                CachedRectTransform.anchorMin = new Vector2(0, CachedRectTransform.anchorMin.y);
                CachedRectTransform.anchorMax = new Vector2(0, CachedRectTransform.anchorMax.y);
                CachedRectTransform.pivot     = new Vector2(0, CachedRectTransform.pivot.y);
            }
            else
            {
                CachedRectTransform.anchorMin = new Vector2(1, CachedRectTransform.anchorMin.y);
                CachedRectTransform.anchorMax = new Vector2(1, CachedRectTransform.anchorMax.y);
                CachedRectTransform.pivot     = new Vector2(1, CachedRectTransform.pivot.y);
            }
        }
Beispiel #19
0
        protected virtual float AlignChild(RectTransform child, ref float offset)
        {
            float directionScale = (direction == AlignDirection.LeftToRight) ? 1 : -1;
            float anchorX        = (direction == AlignDirection.LeftToRight) ? 0 : 1;

            DrivenTransformProperties childProperties =
                DrivenTransformProperties.AnchorMinX
                | DrivenTransformProperties.AnchorMaxX
                | DrivenTransformProperties.AnchoredPositionX;

            tracker.Add(this, child, childProperties);

            child.anchorMin = new Vector2(anchorX, child.anchorMin.y);
            child.anchorMax = new Vector2(anchorX, child.anchorMax.y);
            CustomChild(child, offset);
            float w = child.rect.width * Mathf.Abs(child.localScale.x);

            offset += directionScale * (w * child.pivot.x);
            child.anchoredPosition = new Vector2(offset, child.anchoredPosition.y);
            offset += directionScale * (w * (1.0f - child.pivot.x) + space);
            return(w);
        }
        protected virtual float AlignChild(RectTransform child, ref float offset)
        {
            float directionScale = (direction == AlignDirection.BottomToTop) ? 1 : -1;
            float anchorY        = (direction == AlignDirection.BottomToTop) ? 0 : 1;

            DrivenTransformProperties childProperties =
                DrivenTransformProperties.AnchorMinY
                | DrivenTransformProperties.AnchorMaxY
                | DrivenTransformProperties.AnchoredPositionY;

            tracker.Add(this, child, childProperties);

            child.anchorMin = new Vector2(child.anchorMin.x, anchorY);
            child.anchorMax = new Vector2(child.anchorMax.x, anchorY);
            CustomChild(child, offset);
            float h = child.rect.height * Mathf.Abs(child.localScale.y);

            offset += directionScale * (h * child.pivot.y);
            child.anchoredPosition = new Vector2(child.anchoredPosition.x, offset);
            offset += directionScale * (h * (1.0f - child.pivot.y) + space);
            return(h);
        }
Beispiel #21
0
    private void Layout()
    {
        this.m_Tracker.Clear();
        if (base.transform.childCount == 0)
        {
            return;
        }

        float num = (this.maxAngle - this.minAngle) / (float)base.transform.childCount;

        for (int i = 0; i < base.transform.childCount; i++)
        {
            RectTransform rectTransform = (RectTransform)base.transform.GetChild(i);
            float         num2          = this.startAngle + (float)i * num;
            Vector3       vector        = new Vector3(Mathf.Cos(num2 * 0.0174532924f), Mathf.Sin(num2 * 0.0174532924f));
            rectTransform.localPosition = vector * this.distance;
            DrivenTransformProperties drivenTransformProperties = (DrivenTransformProperties)52998;
            this.m_Tracker.Add(this, rectTransform, drivenTransformProperties);
            rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
            rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
            rectTransform.pivot     = new Vector2(0.5f, 0.5f);
        }
    }
        private void Vector2Field(Rect position, Func <float> xGetter, Action <float> xSetter, Func <float> yGetter, Action <float> ySetter,
                                  DrivenTransformProperties xDriven, DrivenTransformProperties yDriven, SerializedProperty xProperty, SerializedProperty yProperty, GUIContent label)
        {
            EditorGUI.PrefixLabel(position, -1, label);
            float lblW       = EditorGUIUtility.labelWidth;
            int   ident      = EditorGUI.indentLevel;
            Rect  columnRect = this.GetColumnRect(position, 0);
            Rect  rect       = this.GetColumnRect(position, 1);

            EditorGUIUtility.labelWidth = 13f;
            EditorGUI.indentLevel       = 0;

            EditorGUI.BeginProperty(columnRect, Styles.X, xProperty);
            this.FloatField(columnRect, xGetter, xSetter, xDriven, Styles.X);
            EditorGUI.EndProperty();

            EditorGUI.BeginProperty(columnRect, Styles.Y, yProperty);
            this.FloatField(rect, yGetter, ySetter, yDriven, Styles.Y);
            EditorGUI.EndProperty();

            EditorGUIUtility.labelWidth = lblW;
            EditorGUI.indentLevel       = ident;
        }
Beispiel #23
0
    public void CalculateRadial()
    {
        int activeChildCount           = 0;
        List <RectTransform> childList = new List <RectTransform> ();

        for (int i = 0; i < transform.childCount; i++)
        {
            RectTransform child       = transform.GetChild(i) as RectTransform;
            LayoutElement childLayout = child.GetComponent <LayoutElement> ();
            if (child == null || !child.gameObject.activeSelf || (childLayout != null && childLayout.ignoreLayout))
            {
                continue;
            }
            childList.Add(child);
            activeChildCount++;
        }
        m_Tracker.Clear();
        if (activeChildCount == 0)
        {
            return;
        }

        // Set maxAngle and startAngle based on the number of children (cards).
        if (activeChildCount >= 5)
        {
            maxAngle = 40;
        }
        else
        {
            maxAngle = (activeChildCount - 1f) * 10f;
        }
        startAngle = 90 + maxAngle / 2f;

        rectTransform.sizeDelta = new Vector2(radius, radius) * 2f;
        float sAngle     = ((360f) / activeChildCount) * (activeChildCount - 1f);
        float anglOffset = minAngle;

        if (anglOffset > sAngle)
        {
            anglOffset = sAngle;
        }

        // Set the amount of space between the children, as well as the starting angle.
        float fOffsetAngle = maxAngle / (activeChildCount - 1f);
        float fAngle       = startAngle + anglOffset;

        // Set the rotation as a driven property.
        DrivenTransformProperties drivenTransformProperties = DrivenTransformProperties.Anchors | DrivenTransformProperties.AnchoredPosition | DrivenTransformProperties.Pivot;

        if (rotateElements)
        {
            drivenTransformProperties |= DrivenTransformProperties.Rotation;
        }

        // Alter direction for clockwise rotations
        if (clockwise)
        {
            fOffsetAngle *= -1f;
        }

        // Set positions for all children.
        for (int i = 0; i < childList.Count; i++)
        {
            RectTransform child = childList[i];
            if (child != null && child.gameObject.activeSelf)
            {
                // Adding the elements to the tracker stops the user from modifiying their positions via the editor.
                m_Tracker.Add(this, child, drivenTransformProperties);
                Vector3 vPos = new Vector3(Mathf.Cos(fAngle * Mathf.Deg2Rad), Mathf.Sin(fAngle * Mathf.Deg2Rad), 0);
                child.localPosition = vPos * radius;
                // Force objects to be center aligned, this can be changed however I'd suggest you keep all of the objects with the same anchor points.
                child.anchorMin = child.anchorMax = child.pivot = new Vector2(0.5f, 0.5f);
                // Rotate children
                float elementAngle = startElementAngle;
                if (rotateElements)
                {
                    elementAngle          += fAngle;
                    child.localEulerAngles = new Vector3(0f, 0f, elementAngle);
                }
                else
                {
                    child.localEulerAngles = new Vector3(0f, 0f, elementAngle);
                }

                fAngle += fOffsetAngle;
            }
        }
    }
        private void FloatField(Rect position, Func <float> getter, Action <float> setter, DrivenTransformProperties driven, GUIContent label, bool labelAbove = false)
        {
            float val = getter();

            EditorGUI.BeginChangeCheck();

            float newVal;

            if (labelAbove)
            {
                int controlID = GUIUtility.GetControlID(BetterLocatorEditor.floatFieldHash, FocusType.Keyboard, position);

                Rect rect  = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
                Rect rect1 = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight, position.width, EditorGUIUtility.singleLineHeight);
                EditorGUI.HandlePrefixLabel(position, rect, label, controlID);

                EditorGUI.PrefixLabel(rect, label);
                newVal = EditorGUI.FloatField(rect1, val);
            }
            else
            {
                newVal = EditorGUI.FloatField(position, label, val);
            }


            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(base.target, "Inspector");
                setter(newVal);
            }
        }
Beispiel #25
0
//#if UNITY_EDITOR
//
//        protected override void OnValidate()
//        {
//            base.OnValidate();
//            CalculateRadial();
//        }
//
//#endif

        #endregion

        #region Public Methods

        /// <summary> Rebuild the layout </summary>
        public void CalculateRadial()
        {
            if (m_childList == null)
            {
                m_childList = new List <RectTransform>();
            }
            m_childList.Clear();
            int activeChildCount = 0;

            for (int i = 0; i < transform.childCount; i++)
            {
                var child = transform.GetChild(i) as RectTransform;
                if (child == null)
                {
                    continue;
                }

                var childButton = child.GetComponent <UIButton>();
                if (childButton != null)
                {
                    childButton.UpdateStartValues();
                }

                var childToggle = child.GetComponent <UIToggle>();
                if (childToggle != null)
                {
                    childToggle.UpdateStartValues();
                }

                var childLayout = child.GetComponent <LayoutElement>();
                if (child == null || !child.gameObject.activeSelf || (childLayout != null && childLayout.ignoreLayout))
                {
                    continue;
                }
                m_childList.Add(child);
                activeChildCount++;
            }

            m_Tracker.Clear();
            if (activeChildCount == 0)
            {
                return;
            }

            RectTransform.sizeDelta = new Vector2(m_Radius, m_Radius) * 2f;

            float sAngle      = 360f / activeChildCount * (activeChildCount - 1f);
            float angleOffset = m_MinAngle;

            if (angleOffset > sAngle)
            {
                angleOffset = sAngle;
            }
            float maxAngle = 360f - m_MaxAngle;

            if (maxAngle > sAngle)
            {
                maxAngle = sAngle;
            }
            if (angleOffset > sAngle)
            {
                angleOffset = sAngle;
            }
            float buff                = sAngle - angleOffset;
            float fOffsetAngle        = ((buff - maxAngle)) / (activeChildCount - 1f) + m_Spacing;
            float fAngle              = m_StartAngle + angleOffset;
            bool  controlChildrenSize = m_ControlChildWidth | m_ControlChildHeight;

            DrivenTransformProperties drivenTransformProperties = DrivenTransformProperties.Anchors | DrivenTransformProperties.AnchoredPosition | DrivenTransformProperties.Pivot;

            if (m_ControlChildWidth)
            {
                drivenTransformProperties |= DrivenTransformProperties.SizeDeltaX;
            }
            if (m_ControlChildHeight)
            {
                drivenTransformProperties |= DrivenTransformProperties.SizeDeltaY;
            }
            if (m_RotateChildren)
            {
                drivenTransformProperties |= DrivenTransformProperties.Rotation;
            }

            if (m_Clockwise)
            {
                fOffsetAngle *= -1f;
            }

            foreach (RectTransform child in m_childList)
            {
                if (child == null || !child.gameObject.activeSelf)
                {
                    continue;                                                                                    //if child is null or not active -> continue
                }
                m_Tracker.Add(this, child, drivenTransformProperties);                                           //add elements to the tracker to stop the user from modifying their positions via the editor
                var vPos = new Vector3(Mathf.Cos(fAngle * Mathf.Deg2Rad), Mathf.Sin(fAngle * Mathf.Deg2Rad), 0); //calculate the child position
                child.localPosition = vPos * m_Radius;                                                           //set the child position
                child.anchorMin     = child.anchorMax = child.pivot = new Vector2(0.5f, 0.5f);                   //force children to be center aligned, to keep all of the objects with the same anchor points

                float elementAngle = m_ChildRotation;
                if (m_RotateChildren)
                {
                    elementAngle += fAngle;
                }
                child.localEulerAngles = new Vector3(0f, 0f, elementAngle);

                if (controlChildrenSize)
                {
                    Vector2 childSizeDelta = child.sizeDelta;

                    if (ControlChildWidth)
                    {
                        childSizeDelta.x = m_RadiusControlsWidth
                                               ? m_ChildWidth * m_Radius * m_RadiusWidthFactor / 100
                                               : m_ChildWidth;
                    }

                    if (ControlChildHeight)
                    {
                        childSizeDelta.y = m_RadiusControlsHeight
                                               ? m_ChildHeight * m_Radius * m_RadiusHeightFactor / 100
                                               : m_ChildHeight;
                    }

                    child.sizeDelta = childSizeDelta;
                }

                fAngle += fOffsetAngle;
            }
        }
 protected void SetChildAlongAxis(RectTransform rect, int axis, float pos, float size, DrivenTransformProperties properties)
 {
     if (!rect)
     {
         return;
     }
     m_Tracker.Add(this, rect, properties);
     rect.SetInsetAndSizeFromParentEdge(axis != 0 ? RectTransform.Edge.Bottom : RectTransform.Edge.Left, pos, size);
 }
		private void FloatFieldLabelAbove(Rect position, RectTransformEditor.FloatGetter getter, RectTransformEditor.FloatSetter setter, DrivenTransformProperties driven, GUIContent label)
		{
			EditorGUI.BeginDisabledGroup(base.targets.Any((UnityEngine.Object x) => ((x as RectTransform).drivenProperties & driven) != DrivenTransformProperties.None));
			float value = getter(this.target as RectTransform);
			EditorGUI.showMixedValue = ((
				from x in base.targets
				select getter(x as RectTransform)).Distinct<float>().Count<float>() >= 2);
			EditorGUI.BeginChangeCheck();
			int controlID = GUIUtility.GetControlID(RectTransformEditor.s_FloatFieldHash, FocusType.Keyboard, position);
			Rect rect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
			Rect position2 = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight, position.width, EditorGUIUtility.singleLineHeight);
			EditorGUI.HandlePrefixLabel(position, rect, label, controlID);
			float f = EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor, position2, rect, controlID, value, EditorGUI.kFloatFieldFormatString, EditorStyles.textField, true);
			if (EditorGUI.EndChangeCheck())
			{
				Undo.RecordObjects(base.targets, "Inspector");
				UnityEngine.Object[] targets = base.targets;
				for (int i = 0; i < targets.Length; i++)
				{
					RectTransform rect2 = (RectTransform)targets[i];
					setter(rect2, f);
				}
			}
			EditorGUI.EndDisabledGroup();
		}
 private void FloatFieldLabelAbove(Rect position, RectTransformEditor.FloatGetter getter, RectTransformEditor.FloatSetter setter, DrivenTransformProperties driven, GUIContent label)
 {
   // ISSUE: object of a compiler-generated type is created
   // ISSUE: variable of a compiler-generated type
   RectTransformEditor.\u003CFloatFieldLabelAbove\u003Ec__AnonStorey98 aboveCAnonStorey98 = new RectTransformEditor.\u003CFloatFieldLabelAbove\u003Ec__AnonStorey98();
   // ISSUE: reference to a compiler-generated field
   aboveCAnonStorey98.driven = driven;
   // ISSUE: reference to a compiler-generated field
   aboveCAnonStorey98.getter = getter;
   // ISSUE: reference to a compiler-generated method
   EditorGUI.BeginDisabledGroup(((IEnumerable<UnityEngine.Object>) this.targets).Any<UnityEngine.Object>(new Func<UnityEngine.Object, bool>(aboveCAnonStorey98.\u003C\u003Em__1AD)));
   // ISSUE: reference to a compiler-generated field
   float num = aboveCAnonStorey98.getter(this.target as RectTransform);
   // ISSUE: reference to a compiler-generated method
   EditorGUI.showMixedValue = ((IEnumerable<UnityEngine.Object>) this.targets).Select<UnityEngine.Object, float>(new Func<UnityEngine.Object, float>(aboveCAnonStorey98.\u003C\u003Em__1AE)).Distinct<float>().Count<float>() >= 2;
   EditorGUI.BeginChangeCheck();
   int controlId = GUIUtility.GetControlID(RectTransformEditor.s_FloatFieldHash, FocusType.Keyboard, position);
   Rect rect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
   Rect position1 = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight, position.width, EditorGUIUtility.singleLineHeight);
   EditorGUI.HandlePrefixLabel(position, rect, label, controlId);
   float f = EditorGUI.DoFloatField(EditorGUI.s_RecycledEditor, position1, rect, controlId, num, EditorGUI.kFloatFieldFormatString, EditorStyles.textField, true);
   if (EditorGUI.EndChangeCheck())
   {
     Undo.RecordObjects(this.targets, "Inspector");
     foreach (RectTransform target in this.targets)
       setter(target, f);
   }
   EditorGUI.EndDisabledGroup();
 }
		private void Vector2Field(Rect position, RectTransformEditor.FloatGetter xGetter, RectTransformEditor.FloatSetter xSetter, RectTransformEditor.FloatGetter yGetter, RectTransformEditor.FloatSetter ySetter, DrivenTransformProperties xDriven, DrivenTransformProperties yDriven, SerializedProperty xProperty, SerializedProperty yProperty, GUIContent label)
		{
			EditorGUI.PrefixLabel(position, -1, label);
			float labelWidth = EditorGUIUtility.labelWidth;
			int indentLevel = EditorGUI.indentLevel;
			Rect columnRect = this.GetColumnRect(position, 0);
			Rect columnRect2 = this.GetColumnRect(position, 1);
			EditorGUIUtility.labelWidth = 13f;
			EditorGUI.indentLevel = 0;
			EditorGUI.BeginProperty(columnRect, RectTransformEditor.s_XYLabels[0], xProperty);
			this.FloatField(columnRect, xGetter, xSetter, xDriven, RectTransformEditor.s_XYLabels[0]);
			EditorGUI.EndProperty();
			EditorGUI.BeginProperty(columnRect, RectTransformEditor.s_XYLabels[1], yProperty);
			this.FloatField(columnRect2, yGetter, ySetter, yDriven, RectTransformEditor.s_XYLabels[1]);
			EditorGUI.EndProperty();
			EditorGUIUtility.labelWidth = labelWidth;
			EditorGUI.indentLevel = indentLevel;
		}
 private void FloatField(Rect position, RectTransformEditor.FloatGetter getter, RectTransformEditor.FloatSetter setter, DrivenTransformProperties driven, GUIContent label)
 {
   // ISSUE: object of a compiler-generated type is created
   // ISSUE: variable of a compiler-generated type
   RectTransformEditor.\u003CFloatField\u003Ec__AnonStorey99 fieldCAnonStorey99 = new RectTransformEditor.\u003CFloatField\u003Ec__AnonStorey99();
   // ISSUE: reference to a compiler-generated field
   fieldCAnonStorey99.driven = driven;
   // ISSUE: reference to a compiler-generated field
   fieldCAnonStorey99.getter = getter;
   // ISSUE: reference to a compiler-generated method
   EditorGUI.BeginDisabledGroup(((IEnumerable<UnityEngine.Object>) this.targets).Any<UnityEngine.Object>(new Func<UnityEngine.Object, bool>(fieldCAnonStorey99.\u003C\u003Em__1AF)));
   // ISSUE: reference to a compiler-generated field
   float num = fieldCAnonStorey99.getter(this.target as RectTransform);
   // ISSUE: reference to a compiler-generated method
   EditorGUI.showMixedValue = ((IEnumerable<UnityEngine.Object>) this.targets).Select<UnityEngine.Object, float>(new Func<UnityEngine.Object, float>(fieldCAnonStorey99.\u003C\u003Em__1B0)).Distinct<float>().Count<float>() >= 2;
   EditorGUI.BeginChangeCheck();
   float f = EditorGUI.FloatField(position, label, num);
   if (EditorGUI.EndChangeCheck())
   {
     Undo.RecordObjects(this.targets, "Inspector");
     foreach (RectTransform target in this.targets)
       setter(target, f);
   }
   EditorGUI.EndDisabledGroup();
 }
		private void FloatField(Rect position, RectTransformEditor.FloatGetter getter, RectTransformEditor.FloatSetter setter, DrivenTransformProperties driven, GUIContent label)
		{
			EditorGUI.BeginDisabledGroup(base.targets.Any((UnityEngine.Object x) => ((x as RectTransform).drivenProperties & driven) != DrivenTransformProperties.None));
			float value = getter(this.target as RectTransform);
			EditorGUI.showMixedValue = ((
				from x in base.targets
				select getter(x as RectTransform)).Distinct<float>().Count<float>() >= 2);
			EditorGUI.BeginChangeCheck();
			float f = EditorGUI.FloatField(position, label, value);
			if (EditorGUI.EndChangeCheck())
			{
				Undo.RecordObjects(base.targets, "Inspector");
				UnityEngine.Object[] targets = base.targets;
				for (int i = 0; i < targets.Length; i++)
				{
					RectTransform rect = (RectTransform)targets[i];
					setter(rect, f);
				}
			}
			EditorGUI.EndDisabledGroup();
		}
 // Methods
 public void Add(Object driver, RectTransform rectTransform, DrivenTransformProperties drivenProperties)
 {
 }                                                                                                                  // 0x0000000180002ED0-0x0000000180002EE0
Beispiel #33
0
    public void CalculateRadial()
    {
        int activeChildCount           = 0;
        List <RectTransform> childList = new List <RectTransform> ();

        for (int i = 0; i < transform.childCount; i++)
        {
            RectTransform child       = transform.GetChild(i) as RectTransform;
            LayoutElement childLayout = child.GetComponent <LayoutElement> ();
            if (child == null || !child.gameObject.activeSelf || (childLayout != null && childLayout.ignoreLayout))
            {
                continue;
            }
            childList.Add(child);
            activeChildCount++;
        }

        m_Tracker.Clear();
        if (activeChildCount == 0)
        {
            return;
        }

        rectTransform.sizeDelta = new Vector2(radius, radius) * 2f;
        float sAngle = ((360f) / activeChildCount) * (activeChildCount - 1f);

        float anglOffset = minAngle;

        if (anglOffset > sAngle)
        {
            anglOffset = sAngle;
        }

        float buff = sAngle - anglOffset;

        float maxAngl = 360f - maxAngle;

        if (maxAngl > sAngle)
        {
            maxAngl = sAngle;
        }

        if (anglOffset > sAngle)
        {
            anglOffset = sAngle;
        }

        buff = sAngle - anglOffset;

        float fOffsetAngle     = ((buff - maxAngl)) / (activeChildCount - 1f);
        float fAngle           = startAngle + anglOffset;
        float countWidthFactor = fOffsetAngle < maxWidthFactor ? fOffsetAngle : maxWidthFactor;

        bool expandChilds = expandChildWidth | expandChildHeight;
        DrivenTransformProperties drivenTransformProperties = DrivenTransformProperties.Anchors | DrivenTransformProperties.AnchoredPosition | DrivenTransformProperties.Pivot;

        if (expandChildWidth)
        {
            drivenTransformProperties |= DrivenTransformProperties.SizeDeltaX;
        }
        if (expandChildHeight)
        {
            drivenTransformProperties |= DrivenTransformProperties.SizeDeltaY;
        }
        if (rotateElements)
        {
            drivenTransformProperties |= DrivenTransformProperties.Rotation;
        }

        if (clockwise)
        {
            fOffsetAngle *= -1f;
        }

        for (int i = 0; i < childList.Count; i++)
        {
            RectTransform child = childList[i];
            if (child != null && child.gameObject.activeSelf)
            {
                //Adding the elements to the tracker stops the user from modifiying their positions via the editor.
                m_Tracker.Add(this, child, drivenTransformProperties);
                Vector3 vPos = new Vector3(Mathf.Cos(fAngle * Mathf.Deg2Rad), Mathf.Sin(fAngle * Mathf.Deg2Rad), 0);
                child.localPosition = vPos * radius;
                //Force objects to be center aligned, this can be changed however I'd suggest you keep all of the objects with the same anchor points.
                child.anchorMin = child.anchorMax = child.pivot = new Vector2(0.5f, 0.5f);

                float elementAngle = startElementAngle;
                if (rotateElements)
                {
                    elementAngle          += fAngle;
                    child.localEulerAngles = new Vector3(0f, 0f, elementAngle);
                }
                else
                {
                    child.localEulerAngles = new Vector3(0f, 0f, elementAngle);
                }

                if (expandChilds)
                {
                    Vector2 expandSize = child.sizeDelta;
                    if (expandChildWidth)
                    {
                        expandSize.x = childWidthFromRadius ? (radius * childWidthRadiusFactor) * countWidthFactor * childWidthFactor : countWidthFactor * childWidthFactor;
                    }
                    if (expandChildHeight)
                    {
                        expandSize.y = childHeightFromRadius ? (radius * childHeightRadiusFactor) * childHeight : childHeight;
                    }
                    child.sizeDelta = expandSize;
                }

                fAngle += fOffsetAngle;
            }
        }
    }
        protected virtual void SetLayout(int axis)
        {
            if (scrollRect == null)
            {
                return;
            }

            if (axis != GetAxisIndex())
            {
                return;
            }

            if (m_LockSetLayout)
            {
                m_DirtyLayout = true;
                return;
            }

            Vector2 scrollAreaSize = GetScrollAreaSize();

            m_Tracker.Clear();
            rectChildren.Clear();
            m_itemOffsetList.Clear();
            m_pickerItemList.Clear();
            m_childTransformList.Clear();
            cacheRect.Clear();

            bool infinite    = m_ScrollRect.infiniteScroll;
            bool wheelEffect = m_ScrollRect.wheelEffect;

            WheelEffect3D wheelEffect3D = GetComponentInParent <WheelEffect3D>();

            if (wheelEffect3D != null)
            {
                if (wheelEffect3D.IsActive() && (int)wheelEffect3D.layout == axis)
                {
                    wheelEffect = true;
                }
                else
                {
                    wheelEffect3D = null;
                }
            }

            DrivenTransformProperties childDriven = GetChildPropertyDriven(axis, wheelEffect);
            float position   = (!infinite ? scrollAreaSize[axis] * 0.5f : 0);
            float scrollSize = position;

            for (int childIndex = 0; childIndex < rectTransform.childCount; childIndex++)
            {
                Transform     childTransform = rectTransform.GetChild(childIndex);
                RectTransform childRectTransform;
                ItemComponent itemComponent;
                PickerItem    item;

                if (!m_ChildItemTable.TryGetValue(childTransform, out itemComponent))
                {
                    childRectTransform = childTransform as RectTransform;
                    item = childRectTransform.GetComponent <PickerItem>();
                    m_ChildItemTable[childTransform] = new ItemComponent()
                    {
                        item = item, rectTransform = childRectTransform
                    };
                }
                else
                {
                    childRectTransform = itemComponent.rectTransform;
                    item = itemComponent.item;
                }

                if (item == null || !item.enabled || !childRectTransform.gameObject.activeInHierarchy)
                {
                    continue;
                }

                rectChildren.Add(childRectTransform);

                m_pickerItemList.Add(item);
                m_itemOffsetList.Add(0);
                m_childTransformList.Add(childRectTransform);

                m_Tracker.Add(this, childRectTransform, childDriven);

                {
                    Vector2 anchorMin = childRectTransform.anchorMin;

                    if (anchorMin[axis] != 0.5f)
                    {
                        anchorMin[axis] = 0.5f;
                        childRectTransform.anchorMin = anchorMin;
                    }

                    Vector2 anchorMax = childRectTransform.anchorMax;

                    if (anchorMax[axis] != 0.5f)
                    {
                        anchorMax[axis] = 0.5f;
                        childRectTransform.anchorMax = anchorMax;
                    }
                }

                Rect rect = childRectTransform.rect;
                cacheRect.Add(rect);
                float size = rect.size[axis];
                scrollSize += spacing + size;
            }

            if (m_childTransformList.Count > 0 && !infinite)
            {
                float size = m_childTransformList[0].rect.size[axis];
                position   -= size * 0.5f;
                scrollSize -= size * 0.5f;

                size        = m_childTransformList[m_childTransformList.Count - 1].rect.size[axis];
                scrollSize -= size * 0.5f;

                scrollSize -= spacing;
            }

            if (!infinite)
            {
                float flex = Mathf.Min(scrollSize * 0.002f, 0.1f);
                scrollSize += scrollAreaSize[axis] * 0.5f + flex + flex;
                position   += flex;
            }

            SetContentRectSize(axis, scrollSize);

            position += scrollSize * -0.5f;

            float pivot         = m_ChildPivot - 0.5f;
            float direction     = (axis == 0 ? 1f : -1f);
            float wheelPosition = scrollRect.content.localPosition[axis] * -direction;

            float infiniteOffsetFloor = 0;

            if (infinite)
            {
                infiniteOffsetFloor = Mathf.Floor(wheelPosition / scrollSize) * scrollSize;
            }

            if (wheelEffect)
            {
                float perspective   = m_ScrollRect.wheelPerspective;
                float wheelRadius   = wheelEffect3D != null ? wheelEffect3D.radius : scrollAreaSize[axis] * 0.5f;
                float circumference = (wheelRadius + wheelRadius) * Mathf.PI;
                float ru            = (Mathf.PI + Mathf.PI) / circumference * direction;

                for (int childIndex = 0; childIndex < m_childTransformList.Count; ++childIndex)
                {
                    RectTransform childTransform = m_childTransformList[childIndex];

                    float size = cacheRect[childIndex].size[axis];

                    float tmp;

                    if (!infinite)
                    {
                        tmp = position + size * 0.5f;
                    }
                    else
                    {
                        tmp = infiniteOffsetFloor + position + size * 0.5f;

                        if (Mathf.Abs(tmp - wheelPosition) > Mathf.Abs(tmp + scrollSize - wheelPosition))
                        {
                            tmp += scrollSize;
                        }
                    }

                    position += size + spacing;
                    float rad = (tmp - wheelPosition) * ru;

                    float offset = tmp * direction;
                    m_itemOffsetList[childIndex] = offset;
                    PickerItem item = m_pickerItemList[childIndex];
                    item.position = -offset;

                    if (Mathf.Abs(rad) < Mathf.PI * 0.5f)
                    {
                        if (wheelEffect3D == null)
                        {
                            float   scale      = Mathf.Cos(rad);
                            Vector3 localScale = childTransform.localScale;
                            localScale[axis] = scale;

                            float scale2 = (1 - perspective) + scale * perspective;
                            localScale[1 - axis]      = scale2;
                            childTransform.localScale = localScale;

                            Vector2 center        = cacheRect[childIndex].center;
                            Vector3 childPosition = Vector2.zero;
                            childPosition[axis] = Mathf.Sin(rad) * wheelRadius + wheelPosition * direction - center[axis] * scale;

                            float childPivot     = childTransform.pivot[1 - axis] - 0.5f;
                            float childAnchorMin = childTransform.anchorMin[1 - axis];
                            float childAnchorMax = childTransform.anchorMax[1 - axis];
                            float revision       = (childPivot * (childAnchorMax - childAnchorMin) + (childAnchorMax + childAnchorMin - 1) * 0.5f) * scrollAreaSize[1 - axis];
                            childPosition[1 - axis] = (scrollAreaSize[1 - axis] - cacheRect[childIndex].size[1 - axis] * scale2) * pivot - center[1 - axis] * scale2 - revision;

                            childPosition.z = 0;
                            childTransform.localPosition = childPosition;

                            if (childTransform.localRotation != Quaternion.identity)
                            {
                                childTransform.localRotation = Quaternion.identity;
                            }
                        }
                        else
                        {
                            Vector2 center        = cacheRect[childIndex].center;
                            Vector3 childPosition = Vector3.zero;
                            childPosition[axis] = Mathf.Sin(rad) * wheelRadius + wheelPosition * direction - center[axis];

                            Vector3 eulerAngles = childTransform.localRotation.eulerAngles;
                            eulerAngles[1 - axis]        = rad * -Mathf.Rad2Deg * direction;
                            childTransform.localRotation = Quaternion.Euler(eulerAngles);

                            float childPivot     = childTransform.pivot[1 - axis] - 0.5f;
                            float childAnchorMin = childTransform.anchorMin[1 - axis];
                            float childAnchorMax = childTransform.anchorMax[1 - axis];
                            float revision       = (childPivot * (childAnchorMax - childAnchorMin) + (childAnchorMax + childAnchorMin - 1) * 0.5f) * scrollAreaSize[1 - axis];
                            childPosition[1 - axis] = (scrollAreaSize[1 - axis] - cacheRect[childIndex].size[1 - axis]) * pivot - center[1 - axis] - revision;

                            childPosition.z = wheelRadius - Mathf.Cos(rad) * wheelRadius;

                            if (childTransform.localScale != Vector3.one)
                            {
                                childTransform.localScale = Vector3.one;
                            }

                            childTransform.localPosition = childPosition;
                        }
                    }
                    else
                    {
                        Vector3 scale = childTransform.localScale;

                        if (scale.x != 0 || scale.y != 0)
                        {
                            scale.x = 0;
                            scale.y = 0;
                            childTransform.localScale = scale;
                        }
                    }
                }
            }
            else
            {
                for (int childIndex = 0; childIndex < m_childTransformList.Count; ++childIndex)
                {
                    RectTransform childTransform = m_childTransformList[childIndex];
                    PickerItem    item           = m_pickerItemList[childIndex];

                    Rect  rect = childTransform.rect;
                    float size = rect.size[axis];
                    float tmp;

                    if (!infinite)
                    {
                        tmp = position + size * 0.5f;
                    }
                    else
                    {
                        tmp = infiniteOffsetFloor + position + size * 0.5f;

                        if (Mathf.Abs(tmp - wheelPosition) > Mathf.Abs(tmp + scrollSize - wheelPosition))
                        {
                            tmp += scrollSize;
                        }
                    }

                    float offset = tmp * direction;
                    m_itemOffsetList[childIndex] = offset;
                    item.position = -offset;
                    position     += size + spacing;

                    Vector3 childPosition = childTransform.anchoredPosition;
                    childPosition[axis] = tmp * direction - rect.center[axis];

                    float childPivot     = childTransform.pivot[1 - axis] - 0.5f;
                    float childAnchorMin = childTransform.anchorMin[1 - axis];
                    float childAnchorMax = childTransform.anchorMax[1 - axis];
                    float revision       = (childPivot * (childAnchorMax - childAnchorMin) + (childAnchorMax + childAnchorMin - 1) * 0.5f) * scrollAreaSize[1 - axis];

                    childPosition[1 - axis] = (scrollAreaSize[1 - axis] - rect.size[1 - axis]) * pivot - rect.center[1 - axis] - revision;
                    childPosition.z         = 0;

                    if (childTransform.localPosition != childPosition)
                    {
                        childTransform.localPosition = childPosition;
                    }

                    if (childTransform.localRotation != Quaternion.identity)
                    {
                        childTransform.localRotation = Quaternion.identity;
                    }

                    if (childTransform.localScale != Vector3.one)
                    {
                        childTransform.localScale = Vector3.one;
                    }
                }
            }

            if (direction < 0)
            {
                m_itemOffsetList.Reverse();
                m_pickerItemList.Reverse();
            }

            int infiniteScrollOffset = 0;

            if (infinite)
            {
                //sort offset & item
                int i;
                int count = m_itemOffsetList.Count;

                if (count > 1)
                {
                    for (i = 1; i < count; ++i)
                    {
                        if (m_itemOffsetList[i - 1] >= m_itemOffsetList[i])
                        {
                            break;
                        }
                    }

                    infiniteScrollOffset = i;

                    if (i < count)
                    {
                        if (swapBufferOffset == null || i > swapBufferOffset.Length)
                        {
                            swapBufferOffset = new float[i];
                            swapBufferItem   = new PickerItem[i];
                        }

                        m_itemOffsetList.CopyTo(0, swapBufferOffset, 0, i);
                        m_pickerItemList.CopyTo(0, swapBufferItem, 0, i);

                        int j;

                        for (j = 0; j + i < count; ++j)
                        {
                            m_itemOffsetList[j] = m_itemOffsetList[j + i];
                            m_pickerItemList[j] = m_pickerItemList[j + i];
                        }

                        for (int k = 0; k + j < count; ++k)
                        {
                            m_itemOffsetList[k + j] = swapBufferOffset[k];
                            m_pickerItemList[k + j] = swapBufferItem[k];
                        }
                    }
                }
            }

            if (scrollRect != null && Application.isPlaying)
            {
                scrollRect.SetInitialPosition(infiniteScrollOffset);
            }
        }
 //
 // Summary:
 //     Resume recording undo of driven RectTransforms.
 //public static void StartRecordingUndo();
 //
 // Summary:
 //     Stop recording undo actions from driven RectTransforms.
 //public static void StopRecordingUndo();
 //
 // Summary:
 //     Add a RectTransform to be driven.
 //
 // Parameters:
 //   driver:
 //     The object to drive properties.
 //
 //   rectTransform:
 //     The RectTransform to be driven.
 //
 //   drivenProperties:
 //     The properties to be driven.
 public void Add(Object driver, RectTransform rectTransform, DrivenTransformProperties drivenProperties)
 {
 }
 private void FloatFieldLabelAbove(Rect position, Func <float> getter, Action <float> setter, DrivenTransformProperties driven, GUIContent label)
 {
     FloatField(position, getter, setter, driven, label, true);
 }