コード例 #1
0
        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);
        }
コード例 #2
0
        protected void DrawOverrideCheckbox(SerializedDataParameter property)
        {
            var overrideRect = GUILayoutUtility.GetRect(17f, 17f, GUILayout.ExpandWidth(false));

            overrideRect.yMin += 4f;
            property.overrideState.boolValue = GUI.Toggle(overrideRect, property.overrideState.boolValue, EditorGUIUtility.TrTextContent("", "Override this setting for this volume."), CoreEditorStyles.smallTickbox);
        }
コード例 #3
0
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

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

            value.vector4Value = EditorGUILayout.Vector4Field(title, value.vector4Value);
            return(true);
        }
コード例 #4
0
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

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

            value.intValue = EditorGUILayout.MaskField(title, value.intValue, InternalEditorUtility.layers);
            return(true);
        }
コード例 #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<NoInterpClampedFloatParameter>();
            EditorGUILayout.Slider(value, o.min, o.max, title);
            value.floatValue = Mathf.Clamp(value.floatValue, o.min, o.max);
            return true;
        }
コード例 #6
0
        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);
        }
コード例 #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 <MinIntParameter>();
            int v = EditorGUILayout.IntField(title, value.intValue);

            value.intValue = Mathf.Max(v, o.min);
            return(true);
        }
コード例 #9
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);
        }
コード例 #10
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);
        }
コード例 #11
0
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

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

            var rect = EditorGUILayout.GetControlRect();

            EditorGUI.BeginProperty(rect, title, value);
            TextureParameterHelper.DoObjectField(rect, value, title, typeof(Texture3D), typeof(RenderTexture), validator);
            EditorGUI.EndProperty();
            return(true);
        }
コード例 #12
0
        public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
        {
            var value = parameter.value;

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

            var lineRect = EditorGUILayout.GetControlRect();

            EditorGUI.BeginProperty(lineRect, title, value);
            value.intValue = FieldToLayerMask(
                EditorGUI.MaskField(lineRect, title, LayerMaskToField(value.intValue), InternalEditorUtility.layers));
            EditorGUI.EndProperty();
            return(true);
        }
コード例 #13
0
        public virtual void OnEnable()
        {
            m_Parameters = new List <SerializedDataParameter>();

            // Grab all valid serializable field on the VolumeComponent
            var fields = target.GetType()
                         .GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                         .Where(t => t.FieldType.IsSubclassOf(typeof(VolumeParameter)))
                         .Where(t =>
                                (t.IsPublic && t.GetCustomAttributes(typeof(NonSerializedAttribute), false).Length == 0) ||
                                (t.GetCustomAttributes(typeof(SerializeField), false).Length > 0)
                                )
                         .Where(t => t.GetCustomAttributes(typeof(HideInInspector), false).Length == 0)
                         .ToList();

            // Prepare all serialized objects for this editor
            foreach (var field in fields)
            {
                var property  = serializedObject.FindProperty(field.Name);
                var parameter = new SerializedDataParameter(property);
                m_Parameters.Add(parameter);
            }
        }
コード例 #14
0
 // Return false is the input parameter is invalid - unity will display the default editor
 // for this control then
 public abstract bool OnGUI(SerializedDataParameter parameter, GUIContent title);
コード例 #15
0
        protected void PropertyField(SerializedDataParameter property, GUIContent title)
        {
            // Handle unity built-in decorators (Space, Header, Tooltip etc)
            foreach (var attr in property.attributes)
            {
                if (attr is PropertyAttribute)
                {
                    if (attr is SpaceAttribute)
                    {
                        EditorGUILayout.GetControlRect(false, (attr as SpaceAttribute).height);
                    }
                    else if (attr is HeaderAttribute)
                    {
                        var rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);
                        rect.y += 0f;
                        rect    = EditorGUI.IndentedRect(rect);
                        EditorGUI.LabelField(rect, (attr as HeaderAttribute).header, EditorStyles.miniLabel);
                    }
                    else if (attr is TooltipAttribute)
                    {
                        if (string.IsNullOrEmpty(title.tooltip))
                        {
                            title.tooltip = (attr as TooltipAttribute).tooltip;
                        }
                    }
                }
            }

            // Custom parameter drawer
            VolumeParameterDrawer drawer;

            s_ParameterDrawers.TryGetValue(property.referenceType, out drawer);

            bool invalidProp = false;

            if (drawer != null && !drawer.IsAutoProperty())
            {
                if (drawer.OnGUI(property, title))
                {
                    return;
                }

                invalidProp = true;
            }

            // ObjectParameter<T> is a special case
            if (VolumeParameter.IsObjectParameter(property.referenceType))
            {
                bool expanded = property.value.isExpanded;
                expanded = EditorGUILayout.Foldout(expanded, title, true);

                if (expanded)
                {
                    EditorGUI.indentLevel++;

                    // Not the fastest way to do it but that'll do just fine for now
                    var  it    = property.value.Copy();
                    var  end   = it.GetEndProperty();
                    bool first = true;

                    while (it.Next(first) && !SerializedProperty.EqualContents(it, end))
                    {
                        PropertyField(Unpack(it));
                        first = false;
                    }

                    EditorGUI.indentLevel--;
                }

                property.value.isExpanded = expanded;
                return;
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                // Override checkbox
                DrawOverrideCheckbox(property);

                // Property
                using (new EditorGUI.DisabledScope(!property.overrideState.boolValue))
                {
                    if (drawer != null && !invalidProp)
                    {
                        if (drawer.OnGUI(property, title))
                        {
                            return;
                        }
                    }

                    // Default unity field
                    EditorGUILayout.PropertyField(property.value, title);
                }
            }
        }
コード例 #16
0
        protected void PropertyField(SerializedDataParameter property)
        {
            var title = EditorGUIUtility.TrTextContent(property.displayName);

            PropertyField(property, title);
        }
コード例 #17
0
 public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
 {
     return(CubemapParameterDrawer.OnGUI(parameter.value, title));
 }
コード例 #18
0
        protected void PropertyField(SerializedDataParameter property)
        {
            var title = CoreEditorUtils.GetContent(property.displayName);

            PropertyField(property, title);
        }