private void DrawPropertySpecific(Rect labelRect, Rect miscRect, Rect defaultRect, ShaderProperty element) { switch (element.PropertyType) { // Range case PropertyType.Range: var rangeProperty = (RangeProperty)element; EditorGUI.LabelField(labelRect, "Range"); var labelWidth1 = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = Utils.TextWidth("Min: "); rangeProperty.MinValue = EditorGUI.FloatField(Utils.Pad(Utils.ShareRect(miscRect, 2, 0), Padding, Padding), "Min: ", rangeProperty.MinValue); EditorGUIUtility.labelWidth = Utils.TextWidth("Max: "); rangeProperty.MaxValue = EditorGUI.FloatField( Utils.Pad(Utils.ShareRect(miscRect, 2, 1), Padding, 0), "Max: ", rangeProperty.MaxValue); EditorGUIUtility.labelWidth = labelWidth1; rangeProperty.DefaultValue = EditorGUI.Slider(defaultRect, rangeProperty.DefaultValue, rangeProperty.MinValue, rangeProperty.MaxValue); break; // Color case PropertyType.Color: var colorProperty = (ColorProperty)element; EditorGUI.LabelField(labelRect, "Color"); colorProperty.DefaultValue = EditorGUI.ColorField(defaultRect, colorProperty.DefaultValue); break; // Texture case PropertyType.Texture: var texProperty = (TextureProperty)element; EditorGUI.LabelField(labelRect, "Texture"); labelWidth1 = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = Utils.TextWidth("Auto UV: "); texProperty.TexGenMode = (TexGenMode)EditorGUI.EnumPopup(miscRect, "Auto UV: ", texProperty.TexGenMode); EditorGUIUtility.labelWidth = labelWidth1; texProperty.DefaultValue = (DefaultTexture)EditorGUI.EnumPopup(defaultRect, texProperty.DefaultValue); break; // Float case PropertyType.Float: var floatProperty = (FloatProperty)element; EditorGUI.LabelField(labelRect, "Float"); floatProperty.DefaultValue = EditorGUI.FloatField(defaultRect, floatProperty.DefaultValue); break; // Vector case PropertyType.Vector: var vecProperty = (VectorProperty)element; EditorGUI.LabelField(labelRect, "Vector"); vecProperty.DefaultValue = SwGui.Vector4Field(defaultRect, vecProperty.DefaultValue); break; default: throw new ArgumentOutOfRangeException(); } }
private void DrawPropertyName(Rect nameRect, ShaderProperty property) { property.Name = EditorGUI.TextField(Utils.Pad(Utils.ShareRect(nameRect, 2, 0), 0, Padding), property.Name); property.DisplayName = EditorGUI.TextField(Utils.Pad(Utils.ShareRect(nameRect, 2, 1), Padding, 0), property.DisplayName); }