Exemplo n.º 1
0
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 {
     EditorGUI.BeginProperty(position, label, property);
     FillProps(property);
     EditorGUIExtensions.DrawPropertesWithLabelProperty(props, property, position);
     EditorGUI.EndProperty();
 }
Exemplo n.º 2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            FillProps(property);
            var h          = EditorGUIExtensions.DrawPropertesWithLabelProperty(props, property, position);
            var rectTransf = GetRectTransform(property);

            if (rectTransf != null && property.isExpanded)
            {
                var y  = position.y + h;
                var pw = position.width * 0.7f - 8f;
                var x  = position.x + position.width - pw - 4f;
                var bw = pw / 6f;

                var rect = rectTransf.rect;

                var anchorProp  = property.FindPropertyRelative("anchor");
                var offsetProp  = property.FindPropertyRelative("offset");
                var anchorPoint = new AnchorPoint()
                {
                    anchor = anchorProp.vector2Value, offset = offsetProp.vector2Value
                };

                //↑←→↓↔↕○□
                if (GUI.Button(new Rect(x, y, bw, bh), "←"))
                {
                    anchorPoint.SetAnchorWithSafePosition(new Vector2(0, anchorPoint.anchor.y), rect);
                }
                x += bw;

                if (GUI.Button(new Rect(x, y, bw, bh), "↑"))
                {
                    anchorPoint.SetAnchorWithSafePosition(new Vector2(anchorPoint.anchor.x, 1), rect);
                }
                x += bw;
                if (GUI.Button(new Rect(x, y, bw, bh), "↓"))
                {
                    anchorPoint.SetAnchorWithSafePosition(new Vector2(anchorPoint.anchor.x, 0), rect);
                }
                x += bw;
                if (GUI.Button(new Rect(x, y, bw, bh), "→"))
                {
                    anchorPoint.SetAnchorWithSafePosition(new Vector2(1, anchorPoint.anchor.y), rect);
                }
                x += bw + 3f;
                if (GUI.Button(new Rect(x, y, bw, bh), "↔"))
                {
                    var nax = (anchorPoint.CalcPos(rect) - rect.position).x / rect.width;
                    anchorPoint.anchor.x = nax;
                    anchorPoint.offset.x = 0;
                }
                x += bw;
                if (GUI.Button(new Rect(x, y, bw, bh), "↕"))
                {
                    var nay = (anchorPoint.CalcPos(rect) - rect.position).y / rect.height;
                    anchorPoint.anchor.y = nay;
                    anchorPoint.offset.y = 0;
                }

                anchorProp.vector2Value = anchorPoint.anchor;
                offsetProp.vector2Value = anchorPoint.offset;
            }

            EditorGUI.EndProperty();
        }