Skip to content

Commit 450f340

Browse files
committed
Implement basic path validation for the SerializedDirectory class; minor refactor changes
1 parent 42deedb commit 450f340

16 files changed

+94
-33
lines changed

Assets/Editor Toolbox/Editor/Drawers/Internal/FolderDataDrawer.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ internal class FolderDataDrawer : PropertyDrawer
1111
private const int largeIconPickedId = 1001;
1212
private const int smallIconPickedId = 1002;
1313

14-
1514
private void DrawFolderByNameIcon(Rect rect)
1615
{
1716
var diff = rect.height - Style.dataByNameLabelStyle.fixedHeight;
@@ -67,7 +66,6 @@ private int GetSelectorHash(SerializedProperty property)
6766
return property.propertyPath.GetHashCode() + property.serializedObject.GetHashCode();
6867
}
6968

70-
7169
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
7270
{
7371
//if expanded - draw foldout + 3 properties + buttons strip + additional icon
@@ -154,35 +152,29 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
154152
EditorGUI.indentLevel++;
155153

156154
var rawPropertyHeight = propertyPosition.height + Style.spacing;
157-
var summaryFieldHeight = rawPropertyHeight;
158155

159156
propertyPosition.y += rawPropertyHeight;
160-
summaryFieldHeight += rawPropertyHeight;
161157
//draw the folder data type property
162158
EditorGUI.PropertyField(propertyPosition, dataTypeProperty, new GUIContent("Type"), false);
163159
propertyPosition.y += rawPropertyHeight;
164-
summaryFieldHeight += rawPropertyHeight;
165160

166161
//decide what property should be drawn depending on the folder data type
167162
if (isPathBased)
168163
{
169164
propertyPosition.height = EditorGUI.GetPropertyHeight(pathProperty);
170165
EditorGUI.PropertyField(propertyPosition, pathProperty, false);
171166
propertyPosition.y += propertyPosition.height + Style.spacing;
172-
summaryFieldHeight += propertyPosition.height + Style.spacing;
173167
propertyPosition.height = Style.height;
174168
}
175169
else
176170
{
177171
EditorGUI.PropertyField(propertyPosition, nameProperty, false);
178172
propertyPosition.y += rawPropertyHeight;
179-
summaryFieldHeight += rawPropertyHeight;
180173
}
181174

182175
propertyPosition.height = EditorGUI.GetPropertyHeight(tooltipProperty);
183176
EditorGUI.PropertyField(propertyPosition, tooltipProperty, false);
184177
propertyPosition.y += propertyPosition.height + Style.spacing;
185-
summaryFieldHeight += propertyPosition.height + Style.spacing;
186178
propertyPosition.height = Style.height;
187179

188180
//adjust rect for folder icons + button strip
@@ -244,7 +236,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
244236
EditorGUI.EndProperty();
245237
}
246238

247-
248239
private static class Style
249240
{
250241
internal static readonly float height = EditorGUIUtility.singleLineHeight;

Assets/Editor Toolbox/Editor/Drawers/Material/BaseMaterialPropertyDrawer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@ protected virtual void DrawInvalidDrawerLabel(Rect position, string label)
2929
EditorGUI.LabelField(position, content);
3030
}
3131

32-
33-
public override sealed float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
32+
public sealed override float GetPropertyHeight(MaterialProperty prop, string label, MaterialEditor editor)
3433
{
3534
return IsPropertyValid(prop)
3635
? GetPropertyHeightSafe(prop, label, editor)
3736
: base.GetPropertyHeight(prop, label, editor);
3837
}
3938

40-
public override sealed void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
39+
public sealed override void OnGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor)
4140
{
4241
if (IsPropertyValid(prop))
4342
{

Assets/Editor Toolbox/Editor/Drawers/Material/MaterialCompactTextureDrawer.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ public class MaterialCompactTextureDrawer : BaseMaterialPropertyDrawer
77
{
88
private readonly string tooltip;
99

10-
1110
public MaterialCompactTextureDrawer() : this(string.Empty)
1211
{ }
1312

@@ -16,7 +15,6 @@ public MaterialCompactTextureDrawer(string tooltip)
1615
this.tooltip = tooltip;
1716
}
1817

19-
2018
protected override float GetPropertyHeightSafe(MaterialProperty prop, string label, MaterialEditor editor)
2119
{
2220
return EditorGUIUtility.singleLineHeight;

Assets/Editor Toolbox/Editor/Drawers/Material/MaterialConditionalDrawer.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ public abstract class MaterialConditionalDrawer : BaseMaterialPropertyDrawer
77
{
88
protected readonly string togglePropertyName;
99

10-
1110
protected MaterialConditionalDrawer(string togglePropertyName)
1211
{
1312
this.togglePropertyName = togglePropertyName;
1413
}
1514

16-
1715
protected override float GetPropertyHeightSafe(MaterialProperty prop, string label, MaterialEditor editor)
1816
{
1917
if (!HasToggle(prop))

Assets/Editor Toolbox/Editor/Drawers/Material/MaterialHelpDecorator.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public class MaterialHelpDecorator : BaseMaterialPropertyDrawer
88
private readonly string message;
99
private readonly MessageType type;
1010

11-
1211
public MaterialHelpDecorator(string message) : this(message, 1)
1312
{
1413
this.message = message;
@@ -20,7 +19,6 @@ public MaterialHelpDecorator(string message, float type)
2019
this.type = (MessageType)type;
2120
}
2221

23-
2422
protected override float GetPropertyHeightSafe(MaterialProperty prop, string label, MaterialEditor editor)
2523
{
2624
var minHeight = 24.0f;
@@ -33,7 +31,6 @@ protected override void OnGUISafe(Rect position, MaterialProperty prop, string l
3331
EditorGUI.HelpBox(position, message, type);
3432
}
3533

36-
3734
private static class Style
3835
{
3936
internal static readonly GUIStyle textStyle = new GUIStyle(EditorStyles.label)

Assets/Editor Toolbox/Editor/Drawers/Material/MaterialHideIfToggleDrawer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ public class MaterialHideIfToggleDrawer : MaterialConditionalDrawer
55
public MaterialHideIfToggleDrawer(string togglePropertyName) : base(togglePropertyName)
66
{ }
77

8-
98
protected override bool IsVisible(bool? value)
109
{
1110
return value.HasValue && !value.Value;

Assets/Editor Toolbox/Editor/Drawers/Material/MaterialIndentDrawer.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ public class MaterialIndentDrawer : BaseMaterialPropertyDrawer
77
{
88
private readonly int indent;
99

10-
1110
public MaterialIndentDrawer() : this(1)
1211
{ }
1312

@@ -16,7 +15,6 @@ public MaterialIndentDrawer(float indent)
1615
this.indent = (int)indent;
1716
}
1817

19-
2018
protected override float GetPropertyHeightSafe(MaterialProperty prop, string label, MaterialEditor editor)
2119
{
2220
return base.GetPropertyHeightSafe(prop, label, editor);

Assets/Editor Toolbox/Editor/Drawers/Material/MaterialMinMaxSliderDrawer.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ public class MaterialMinMaxSliderDrawer : BaseMaterialPropertyDrawer
1010
private readonly float minValue;
1111
private readonly float maxValue;
1212

13-
1413
public MaterialMinMaxSliderDrawer(float minValue, float maxValue)
1514
{
1615
this.minValue = minValue;
1716
this.maxValue = maxValue;
1817
}
1918

20-
2119
protected override float GetPropertyHeightSafe(MaterialProperty prop, string label, MaterialEditor editor)
2220
{
2321
return EditorGUIUtility.singleLineHeight;

Assets/Editor Toolbox/Editor/Drawers/Material/MaterialShowIfToggleDrawer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ public class MaterialShowIfToggleDrawer : MaterialConditionalDrawer
55
public MaterialShowIfToggleDrawer(string togglePropertyName) : base(togglePropertyName)
66
{ }
77

8-
98
protected override bool IsVisible(bool? value)
109
{
1110
return value ?? false;

Assets/Editor Toolbox/Editor/Drawers/Material/MaterialTitleDecorator.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public class MaterialTitleDecorator : BaseMaterialPropertyDrawer
88
private readonly GUIContent header;
99
private readonly float spacing;
1010

11-
1211
public MaterialTitleDecorator(string header) : this(header, 4.0f)
1312
{ }
1413

@@ -18,7 +17,6 @@ public MaterialTitleDecorator(string header, float spacing)
1817
this.spacing = spacing;
1918
}
2019

21-
2220
protected override float GetPropertyHeightSafe(MaterialProperty prop, string label, MaterialEditor editor)
2321
{
2422
return EditorGUIUtility.singleLineHeight + spacing;

0 commit comments

Comments
 (0)