public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (!GetAttribute.DrawButtons)
            {
                property.intValue = EditorGUI.MaskField(position, label, property.intValue, property.enumNames);

                return;
            }

            var buttonsIntValue = 0;
            var labelWidth      = EditorGUIUtility.labelWidth;
            var enumLength      = property.enumNames.Length;
            var buttonPressed   = new bool[enumLength];

            FoCsGUI.Label(new Rect(position.x, position.y, labelWidth, position.height), label);

            using (var cc = Disposables.ChangeCheck()) {
                //if(property.enumNames.Length <= 4)
                buttonsIntValue = DoLessThen4Draw(position, property, buttonsIntValue, labelWidth, enumLength, buttonPressed);
                //else
                //	buttonsIntValue = DoMoreThen4Draw(position, property, buttonsIntValue, labelWidth, enumLength, buttonPressed);

                if (cc.changed)
                {
                    property.intValue = buttonsIntValue;
                }
            }
        }
Пример #2
0
        public static void DoDraw(Rect position, SerializedProperty property, GUIContent label)
        {
            using (var propScope = Disposables.PropertyScope(position, label, property)) {
                position.height = SingleLine;
                label           = propScope.content;
                var labelPos = position.Edit(RectEdit.SetWidth(EditorGUIUtility.labelWidth));
                FoCsGUI.Label(labelPos, label);

                using (var scope = Disposables.RectHorizontalScope(6, position.Edit(RectEdit.AddX(labelPos.width), RectEdit.SetWidth(position.width - labelPos.width)))) {
                    using (Disposables.IndentSet(0)) {
                        using (var innerScope = Disposables.RectHorizontalScope(3, scope.GetNext(2))) {
                            FoCsGUI.Label(innerScope.GetNext(), KEY_LABEL);
                            FoCsGUI.PropertyField(innerScope.GetNext(2), property.FindPropertyRelative(KEY), GUIContent.none);
                        }

                        using (var innerScope = Disposables.RectHorizontalScope(5, scope.GetNext(2))) {
                            FoCsGUI.Label(innerScope.GetNext(2), KEY_TYPE_LABEL);
                            FoCsGUI.PropertyField(innerScope.GetNext(3), property.FindPropertyRelative(KEY_TYPE), GUIContent.none);
                        }

                        using (var innerScope = Disposables.RectHorizontalScope(5, scope.GetNext(2))) {
                            var key     = property.GetTargetObjectOfProperty <AnimatorKey>();
                            var typeStr = GetDisplayString(key);
                            FoCsGUI.Label(innerScope.GetNext(2), LABEL);
                            FoCsGUI.PropertyField(innerScope.GetNext(3), property.FindPropertyRelative(typeStr), GUIContent.none);
                        }
                    }
                }
            }
        }
Пример #3
0
        /// <inheritdoc />
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            using (var prop = Disposables.PropertyScope(position, label, property)) {
                var owner = GetTargetObject(property);
                FoCsGUI.Label(position.Edit(RectEdit.SetHeight(SingleLine)), prop.content);
                DoDragDrop(position.Edit(RectEdit.MultiplyWidth(0.5f)), property);

                using (Disposables.Indent()) {
                    var Position = property.FindPropertyRelative("Position");
                    var Rotation = property.FindPropertyRelative("Rotation");
                    var Scale    = property.FindPropertyRelative("Scale");

                    using (var horizontalScope =
                               Disposables.RectHorizontalScope(5, position.Edit(RectEdit.SetHeight(SingleLine - 2), RectEdit.DivideWidth(2), RectEdit.AddX(position.width * 0.5f)))) {
                        var copyBtn = FoCsGUI.Button(horizontalScope.GetNext(2), CopyContent);
                        var isType  = CopyPasteUtility.IsTypeInBuffer(owner);
                        FoCsGUI.GUIEventBool pasteBtn;

                        using (Disposables.ColorChanger(isType? GUI.color : Color.red))
                            pasteBtn = FoCsGUI.Button(horizontalScope.GetNext(2), PasteContent);

                        var resetBtn = FoCsGUI.Button(horizontalScope.GetNext(1), ResetContent);

                        if (copyBtn)
                        {
                            CopyPasteUtility.Copy(GetTargetObject(property));
                        }
                        else if (pasteBtn)
                        {
                            var tD = CopyPasteUtility.Paste <TransformData>();
                            Undo.RecordObject(property.serializedObject.targetObject, "Paste TD");
                            Position.vector3Value    = tD.Position;
                            Scale.vector3Value       = tD.Scale;
                            Rotation.quaternionValue = tD.Rotation;
                        }
                        else if (resetBtn)
                        {
                            Undo.RecordObject(property.serializedObject.targetObject, "Reset TD");
                            var tD = TransformData.Empty;
                            Position.vector3Value    = tD.Position;
                            Scale.vector3Value       = tD.Scale;
                            Rotation.quaternionValue = tD.Rotation;
                        }
                    }

                    using (var vertScope = Disposables.RectVerticalScope(3, position.Edit(RectEdit.SetHeight(SingleLine * 3), RectEdit.AddY(SingleLine)))) {
                        Vector3PropEditor.Draw(vertScope.GetNext(), Position, PositionContent);
                        QuaternionPropertyDrawer.Draw(vertScope.GetNext(), Rotation, RotationContent);
                        Vector3PropEditor.Draw(vertScope.GetNext(), Scale, ScaleContent);
                    }
                }
            }
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var showLabel = ShowLabel(label.text);

            using (var propScope = Disposables.PropertyScope(position, label, property)) {
                label = propScope.content;

                if (EditorGUI.indentLevel <= 1)
                {
                    position = position.Edit(RectEdit.ChangeX(16f));
                }

                var axisProp         = property.FindPropertyRelative("Axis");
                var ValueInverted    = new EditorEntry("Invert Result", property.FindPropertyRelative("ValueInverted"));
                var OnlyButtonEvents = new EditorEntry("Only Button Events", property.FindPropertyRelative("OnlyButtonEvents"));
                var UseSmoothInput   = new EditorEntry("Use Smooth Input", property.FindPropertyRelative("UseSmoothInput"));
                var Axis             = new EditorEntry($"Axis: {axisProp.stringValue}", axisProp);

                var value = new EditorEntry($"{(ValueInverted.Property.boolValue? "Non Inverted " : "")}Value",
                                            property.FindPropertyRelative(UseSmoothInput.Property.boolValue? "valueSmooth" : "valueRaw"));

                var deadZone = new EditorEntry("DeadZone", property.FindPropertyRelative("deadZone"));

                using (var horizontalScope = Disposables.RectHorizontalScope(2, position)) {
                    using (Disposables.LabelFieldSetWidth(horizontalScope.FirstRect.width * LABEL_SIZE)) {
                        using (var verticalScope = Disposables.RectVerticalScope(showLabel? 5 : 4, horizontalScope.GetNext())) {
                            if (showLabel)
                            {
                                FoCsGUI.Label(verticalScope.GetNext(RectEdit.SetHeight(SingleLine), RectEdit.SubtractX(16f)), label);
                            }

                            DrawDropDown(Axis, verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                            ProgressBar(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)), value);
                            deadZone.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                            OnlyButtonEvents.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                        }

                        using (var verticalScope = Disposables.RectVerticalScope(showLabel? 5 : 4, horizontalScope.GetNext(RectEdit.ChangeX(SingleLine)))) {
                            if (showLabel)
                            {
                                verticalScope.GetNext();
                            }

                            Axis.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                            value.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                            ValueInverted.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                            UseSmoothInput.Draw(verticalScope.GetNext(RectEdit.SetHeight(SingleLine)));
                        }
                    }
                }
            }
        }
Пример #5
0
        public static void DoVector2(Rect position, SerializedProperty property, GUIContent label, RangeAttribute range, Rect pos)
        {
            var vec2 = property.vector2Value;

            FoCsGUI.Label(pos, label);
            pos.x     += 60;
            pos.width -= 60;
            pos.y     += SingleLine;
            FoCsGUI.Label(new Rect(position.x + 30, pos.y, 40, SingleLine), "X:");
            vec2.x = EditorGUI.Slider(pos, "", vec2.x, range.min, range.max);
            pos.y += SingleLine;
            FoCsGUI.Label(new Rect(position.x + 30, pos.y, 40, SingleLine), "Y:");
            vec2.y = EditorGUI.Slider(pos, "", vec2.y, range.min, range.max);
            property.vector2Value = vec2;
        }
Пример #6
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            using (var cc = FoCsEditor.Disposables.ChangeCheck())
            {
                var itemProp   = property.FindPropertyRelative("item");
                var amountProp = property.FindPropertyRelative("amount");

                using (var hScope = FoCsEditor.Disposables.RectHorizontalScope(4, position.Edit(RectEdit.SetHeight(SingleLine))))
                {
                    using (var propScope = FoCsEditor.Disposables.PropertyScope(position, label, property))
                    {
                        if (itemProp.objectReferenceValue == null)
                        {
                            FoCsGUI.Label(hScope.GetNext(), propScope.content);
                        }
                        else
                        {
                            FoCsGUI.Label(hScope.GetNext(RectEdit.ChangeX(16)), propScope.content);
                        }

                        FoCsGUI.PropertyField(hScope.GetNext(2), itemProp);
                        FoCsGUI.PropertyField(hScope.GetNext(), amountProp);
                    }
                }

                if (cc.changed)
                {
                    serializedObject = null;
                }

                if (itemProp.objectReferenceValue == null)
                {
                    return;
                }

                if (serializedObject == null)
                {
                    serializedObject = new SerializedObject(itemProp.objectReferenceValue);
                }
            }

            foldout = DrawReference(position, serializedObject, foldout);
        }
Пример #7
0
 private static void DrawErrorMessage(Rect position, GUIContent label)
 {
     FoCsGUI.Label(position, label.text);
     FoCsGUI.Label(position, "Use Range with float, int, string, Vector2 & Vector3.");
 }