示例#1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            PropertyDrawerHelper.LoadAttributeTooltip(this, label);

            position = position.Right(-16.0f);

            float buttonWidth = 40.0f;
            Rect  preButtonRect, buildButtonRect, postButtonRect;

            Rect propertyRect = position
                                .Right(buttonWidth, out postButtonRect)
                                .Right(buttonWidth, out buildButtonRect)
                                .Right(buttonWidth, out preButtonRect);

            UMakeTarget target;

            UMakeTargetEditor.BuildAction action;

            using (IndentLevel.Do(0))
            {
                EditorGUI.PropertyField(propertyRect, property, GUIContent.none);

                target = property.objectReferenceValue as UMakeTarget;
                action = UMakeTargetEditor.BuildAction.None;

                GUI.enabled = target != null && UMakeTargetEditor.CanBuild;

                if (GUI.Button(preButtonRect, "Pre", EditorStyles.miniButtonLeft))
                {
                    action = UMakeTargetEditor.BuildAction.PreActions;
                }

                if (GUI.Button(buildButtonRect, "Build", EditorStyles.miniButtonMid))
                {
                    action = UMakeTargetEditor.BuildAction.Build;
                }

                if (GUI.Button(postButtonRect, "Post", EditorStyles.miniButtonRight))
                {
                    action = UMakeTargetEditor.BuildAction.PostActions;
                }

                GUI.enabled = true;
            }

            property.serializedObject.ApplyModifiedProperties();

            UMake umake;

            if (UMake.Get().TryGet(out umake) && target != null)
            {
                UMakeTargetEditor.ExecuteAction(target, action);
            }
        }
示例#2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            PropertyDrawerHelper.LoadAttributeTooltip(this, label);

            // Bugged Unity... hacks :(
            if (!property.type.StartsWith("Modifiable"))
            {
                return;
            }

            Rect labelPosition    = position.Left(EditorGUIUtility.labelWidth);
            Rect fieldsPosition   = position.Right(-EditorGUIUtility.labelWidth);
            Rect originalPosition = fieldsPosition.Left(fieldsPosition.width * 0.5f);
            Rect modifiedPosition = fieldsPosition.Right(-fieldsPosition.width * 0.5f);

            EditorGUI.LabelField(labelPosition, label);

            SerializedProperty originalValue = property.GetMemberProperty <ModifiableInt>(m => m.OriginalValue);
            SerializedProperty modifiedValue = property.GetMemberProperty <ModifiableInt>(m => m.ModifiedValue);

            bool modified;

            using (LabelWidth.Do(56.0f))
                using (IndentLevel.Do(0))
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUI.PropertyField(originalPosition, originalValue, new GUIContent("Original"));
                    modified = EditorGUI.EndChangeCheck();

                    using (DisabledGroup.Do(true))
                    {
                        EditorGUI.PropertyField(modifiedPosition, modifiedValue, new GUIContent("Modified"));
                    }
                }

            if (modified)
            {
                originalValue.serializedObject.ApplyModifiedProperties();
                modifiedValue.serializedObject.ApplyModifiedProperties();

                var modifiable = SerializedPropertyHelper.GetValue(fieldInfo, property) as IModifiable;
                modifiable.UpdateModifiedValues();

                originalValue.serializedObject.Update();
                modifiedValue.serializedObject.Update();
            }
        }
示例#3
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            PropertyDrawerHelper.LoadAttributeTooltip(this, label);

            // Bugged Unity... hacks :(
            if (!property.type.EndsWith("Bounds"))
            {
                return;
            }

            Rect labelPosition = new Rect(position);
            Rect minPosition   = new Rect(position);
            Rect maxPosition   = new Rect(position);

            labelPosition.width = EditorGUIUtility.labelWidth;
            minPosition.x       = labelPosition.xMax;
            minPosition.width   = (minPosition.width - labelPosition.width) * 0.5f;
            maxPosition.x       = labelPosition.xMax + minPosition.width;
            maxPosition.width   = minPosition.width;

            EditorGUI.LabelField(labelPosition, label);

            SerializedProperty max = property.GetMemberProperty <IntRange>(b => b.Max);
            SerializedProperty min = property.GetMemberProperty <IntRange>(b => b.Min);

            using (LabelWidth.Do(32.0f))
                using (IndentLevel.Do(0))
                {
                    EditorGUI.BeginChangeCheck();
                    DelayedPropertyField(minPosition, min);
                    DelayedPropertyField(maxPosition, max);
                    if (EditorGUI.EndChangeCheck())
                    {
                        min.serializedObject.ApplyModifiedProperties();
                        max.serializedObject.ApplyModifiedProperties();

                        var validatable = SerializedPropertyHelper.GetValue(fieldInfo, property) as IValidatable;
                        validatable.Validate();

                        min.serializedObject.Update();
                        max.serializedObject.Update();
                    }
                }
        }