public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
            {
                if (parameter.value.propertyType == SerializedPropertyType.Vector2)
                {
                    var   o     = parameter.GetObjectRef <Beautify.MinMaxFloatParameter>();
                    var   range = o.value;
                    float x     = range.x;
                    float y     = range.y;

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.MinMaxSlider(title, ref x, ref y, o.min, o.max);
                    x = EditorGUILayout.FloatField(x, GUILayout.Width(40));
                    y = EditorGUILayout.FloatField(y, GUILayout.Width(40));
                    EditorGUILayout.EndHorizontal();
                    if (EditorGUI.EndChangeCheck())
                    {
                        range.x = x;
                        range.y = y;
                        o.SetValue(new Beautify.MinMaxFloatParameter(range, o.min, o.max));
                    }
                    return(true);
                }
                else
                {
                    EditorGUILayout.PropertyField(parameter.value);
                    return(false);
                }
            }
Ejemplo n.º 2
0
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

            if (value.propertyType != SerializedPropertyType.Integer)
            {
                return(false);
            }

            var o = parameter.GetObjectRef <ScalableSettingLevelParameter>();

            var(level, useOverride) = o.levelAndOverride;

            var rect = GUILayoutUtility.GetRect(0, float.Epsilon, 0, EditorGUIUtility.singleLineHeight);

            // Magic number for padding
            rect.x     += 3;
            rect.y     += 2;
            rect.width -= 3;

            o.levelAndOverride = SerializedScalableSettingValueUI.LevelFieldGUI(
                rect,
                title,
                ScalableSettingSchema.GetSchemaOrNull(ScalableSettingSchemaId.With3Levels),
                level,
                useOverride
                );
            return(true);
        }
Ejemplo n.º 3
0
            public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
            {
                if (parameter.value.propertyType == SerializedPropertyType.Vector2)
                {
                    var   o     = parameter.GetObjectRef <HBAO.MinMaxFloatParameter>();
                    var   range = o.value;
                    float x     = range.x;
                    float y     = range.y;

                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.MinMaxSlider(title, ref x, ref y, o.min, o.max);
                    if (EditorGUI.EndChangeCheck())
                    {
                        range.x = x;
                        range.y = y;
                        o.SetValue(new HBAO.MinMaxFloatParameter(range, o.min, o.max));
                    }
                    return(true);
                }
                else
                {
                    EditorGUILayout.LabelField(title, "Use only with Vector2");
                    return(false);
                }
            }
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

            if (value.propertyType != SerializedPropertyType.Integer)
            {
                return(false);
            }

            var o = parameter.GetObjectRef <ScalableSettingLevelParameter>();

            var(level, useOverride) = o.levelAndOverride;

            var rect = EditorGUILayout.GetControlRect();

            var levelAndOverride = SerializedScalableSettingValueUI.LevelFieldGUI(
                rect,
                title,
                ScalableSettingSchema.GetSchemaOrNull(ScalableSettingSchemaId.With3Levels),
                level,
                useOverride
                );

            value.intValue = ScalableSettingLevelParameter.GetScalableSettingLevelParameterValue(levelAndOverride.level, levelAndOverride.useOverride);
            return(true);
        }
Ejemplo n.º 5
0
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

            if (value.propertyType != SerializedPropertyType.Float)
            {
                return(false);
            }

            var   o               = parameter.GetObjectRef <CascadeEndBorderParameter>();
            float max             = o.normalized ? 100f : o.representationDistance;
            float modifiableValue = value.floatValue * max;

            EditorGUI.BeginChangeCheck();
            var lineRect = EditorGUILayout.GetControlRect();

            EditorGUI.BeginProperty(lineRect, title, value);
            modifiableValue = EditorGUI.Slider(lineRect, title, modifiableValue, 0f, max);
            EditorGUI.EndProperty();
            if (EditorGUI.EndChangeCheck())
            {
                value.floatValue = Mathf.Clamp01(modifiableValue / max);
            }
            return(true);
        }
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

            if (value.propertyType != SerializedPropertyType.Float)
            {
                return(false);
            }

            var   o               = parameter.GetObjectRef <CascadePartitionSplitParameter>();
            float max             = o.normalized ? 100f : o.representationDistance;
            float modifiableValue = value.floatValue * max;

            EditorGUI.BeginChangeCheck();
            modifiableValue = EditorGUILayout.Slider(title, modifiableValue, 0f, max);
            if (EditorGUI.EndChangeCheck())
            {
                modifiableValue /= max;
                value.floatValue = Mathf.Clamp(modifiableValue, o.min, o.max);
            }
            return(true);
        }
        void DrawPropertyField(SerializedDataParameter property, MemberInfo field, bool indent)
        {
            if (indent)
            {
                EditorGUI.indentLevel++;
            }

            var displayName = property.displayName;

            if (field.GetCustomAttribute(typeof(Beautify.DisplayName)) is Beautify.DisplayName displayNameAttrib)
            {
                displayName = displayNameAttrib.name;
            }

            if (property.value.propertyType == SerializedPropertyType.Boolean)
            {
                if (field.GetCustomAttribute(typeof(Beautify.GlobalOverride)) != null)
                {
                    BoolParameter pr   = property.GetObjectRef <BoolParameter>();
                    bool          prev = pr.value;

                    using (new EditorGUILayout.HorizontalScope()) {
                        var overrideRect = GUILayoutUtility.GetRect(17f, 17f, GUILayout.ExpandWidth(false));
                        overrideRect.yMin += 4f;
                        bool value = GUI.Toggle(overrideRect, prev, GUIContent.none);

                        string tooltip = null;
                        if (field.GetCustomAttribute(typeof(TooltipAttribute)) is TooltipAttribute tooltipAttribute)
                        {
                            tooltip = tooltipAttribute.tooltip;
                        }

                        using (new EditorGUI.DisabledScope(!prev)) {
                            EditorGUILayout.LabelField(new GUIContent(displayName, tooltip));
                        }

                        if (value != prev)
                        {
                            pr.value = value;
                            SerializedProperty prop = serializedObject.FindProperty(field.Name);
                            if (prop != null)
                            {
                                var boolProp = prop.FindPropertyRelative("m_Value");
                                if (boolProp != null)
                                {
                                    boolProp.boolValue = value;
                                }
                                if (value)
                                {
                                    var overrideProp = prop.FindPropertyRelative("m_OverrideState");
                                    if (overrideProp != null)
                                    {
                                        overrideProp.boolValue = true;
                                    }
                                }
                            }
                            if (field.GetCustomAttribute(typeof(Beautify.BuildToggle)) != null)
                            {
                                SetStripShaderKeywords();
                            }
                        }
                    }
                }
                else
                {
                    PropertyField(property, new GUIContent(displayName));
                }
            }
            else
            {
                PropertyField(property, new GUIContent(displayName));
            }

            if (indent)
            {
                EditorGUI.indentLevel--;
            }
        }