public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

            if (value.propertyType != SerializedPropertyType.Vector2)
                return false;

            var o = parameter.GetObjectRef<FloatRangeParameter>();
            var v = value.vector2Value;

            // The layout system breaks alignement when mixing inspector fields with custom layouted
            // fields as soon as a scrollbar is needed in the inspector, so we'll do the layout
            // manually instead
            const int kFloatFieldWidth = 50;
            const int kSeparatorWidth = 5;
            float indentOffset = EditorGUI.indentLevel * 15f;
            var lineRect = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight);
            lineRect.xMin += 4f;
            lineRect.y += 2f;
            var labelRect = new Rect(lineRect.x, lineRect.y, EditorGUIUtility.labelWidth - indentOffset, lineRect.height);
            var floatFieldLeft = new Rect(labelRect.xMax, lineRect.y, kFloatFieldWidth + indentOffset, lineRect.height);
            var sliderRect = new Rect(floatFieldLeft.xMax + kSeparatorWidth - indentOffset, lineRect.y, lineRect.width - labelRect.width - kFloatFieldWidth * 2 - kSeparatorWidth * 2, lineRect.height);
            var floatFieldRight = new Rect(sliderRect.xMax + kSeparatorWidth - indentOffset, lineRect.y, kFloatFieldWidth + indentOffset, lineRect.height);

            EditorGUI.PrefixLabel(labelRect, title);
            v.x = EditorGUI.FloatField(floatFieldLeft, v.x);
            EditorGUI.MinMaxSlider(sliderRect, ref v.x, ref v.y, o.min, o.max);
            v.y = EditorGUI.FloatField(floatFieldRight, v.y);

            value.vector2Value = v;
            return true;
        }
Exemplo n.º 2
0
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

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

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

            EditorGUI.BeginChangeCheck();
            var newTexture = EditorGUILayout.ObjectField(title, value.objectReferenceValue, typeof(Texture), false) as Texture;

            if (EditorGUI.EndChangeCheck())
            {
                // Texture field can accept any texture (to allow Cube Render Texture) but we still check the dimension to avoid errors
                if (newTexture != null && newTexture.dimension == TextureDimension.Cube)
                {
                    value.objectReferenceValue = newTexture;
                }
                else
                {
                    if (newTexture != null)
                    {
                        Debug.LogError($"{newTexture} is not a Cubemap. Only textures of Cubemap dimension can be assigned to this field.");
                    }
                    value.objectReferenceValue = null;
                }
            }
            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<NoInterpClampedFloatParameter>();
            EditorGUILayout.Slider(value, o.min, o.max, title);
            value.floatValue = Mathf.Clamp(value.floatValue, o.min, o.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<MinFloatParameter>();
            float v = EditorGUILayout.FloatField(title, value.floatValue);
            value.floatValue = Mathf.Max(v, o.min);
            return true;
        }
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

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

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

            value.colorValue = EditorGUILayout.ColorField(title, value.colorValue, o.showEyeDropper, o.showAlpha, o.hdr);
            return(true);
        }
Exemplo n.º 6
0
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

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

            var o = parameter.GetObjectRef <MinIntParameter>();
            int v = EditorGUILayout.IntField(title, value.intValue);

            value.intValue = Mathf.Max(v, o.min);
            return(true);
        }
Exemplo n.º 7
0
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

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

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

            EditorGUILayout.IntSlider(value, o.min, o.max, title);
            value.intValue = Mathf.Clamp(value.intValue, o.min, o.max);
            return(true);
        }
Exemplo n.º 8
0
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

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

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

            EditorGUILayout.PropertyField(value, title);
            value.intValue = Mathf.Min(value.intValue, o.max);
            return(true);
        }