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)));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            using (var propScope = Disposables.PropertyScope(position, label, property)) {
                label = propScope.content;
                var useGlobalSpaceProp = property.FindPropertyRelative("useGlobalSpace");
                var positionsProp      = property.FindPropertyRelative("Positions");
                var useGlobalBoolRect  = position.Edit(RectEdit.SetHeight(SingleLine));
                position = position.Edit(RectEdit.ChangeY(SingleLine));
                EditorGUI.PropertyField(useGlobalBoolRect, useGlobalSpaceProp);
                var targ = property.GetTargetObjectOfProperty <ITDCurve>();

                if (targ.IsFixedLength)
                {
                    if (positionsProp.arraySize != targ.Length)
                    {
                        positionsProp.arraySize = targ.Length;
                    }
                }

                ListNullCheck(property);
                list.HandleDrawing(position.Edit(RectEdit.ChangeX(16)));
            }
        }