Skip to content

Commit d65032f

Browse files
committed
code cleanup
1 parent 70481fd commit d65032f

File tree

2 files changed

+8
-33
lines changed

2 files changed

+8
-33
lines changed

Assets/Editor/Editor Windows/ScriptableObjectEditorWindow.cs

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class ScriptableObjectEditorWindow : EditorWindow
1818
private List<Type> selectedTypes = new List<Type>(); // Tracks which ScriptableObject types are currently selected for display
1919
private List<Type> availableTypes = new List<Type>(); // Holds all unique ScriptableObject types found in the project
2020

21+
// window:
2122
[MenuItem("Window/Game Config Editor")]
2223
public static void ShowWindow()
2324
{
@@ -57,6 +58,7 @@ private void OnGUI()
5758
GUILayout.Label("No Configs Loaded", EditorStyles.boldLabel);
5859
}
5960

61+
// show configs
6062
ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos);
6163
if (groupedConfigs.Count != 0)
6264
{
@@ -75,7 +77,6 @@ private void OnGUI()
7577
EditorGUILayout.EndHorizontal();
7678
}
7779
}
78-
// Close the scrollable area
7980
EditorGUILayout.EndScrollView();
8081
}
8182

@@ -162,38 +163,12 @@ private void PutPropertiesForObject<T>(List<T> Configs) where T : ScriptableObje
162163
{
163164
if (property.propertyType != SerializedPropertyType.ArraySize && property.name != "m_Script" && property.name != "data") // Skip unwanted properties
164165
{
165-
// Generate an appropriate UI control based on the property's data type
166-
switch (property.propertyType)
166+
EditorGUILayout.PropertyField(property, GUIContent.none, true, GUIL_DefaultOptions);
167+
if (property.isExpanded)
167168
{
168-
case SerializedPropertyType.String:
169-
string oldStringValue = property.stringValue;
170-
property.stringValue = EditorGUILayout.TextField(oldStringValue, GUIL_StandartOptions);
171-
break;
172-
case SerializedPropertyType.Integer:
173-
int oldIntValue = property.intValue;
174-
property.intValue = EditorGUILayout.IntField(oldIntValue, GUIL_StandartOptions);
175-
break;
176-
case SerializedPropertyType.Float:
177-
float oldFloatValue = property.floatValue;
178-
property.floatValue = EditorGUILayout.FloatField(oldFloatValue, GUIL_StandartOptions);
179-
break;
180-
case SerializedPropertyType.Boolean:
181-
bool oldBoolValue = property.boolValue;
182-
property.boolValue = EditorGUILayout.Toggle(oldBoolValue, GUIL_StandartOptions);
183-
break;
184-
case SerializedPropertyType.Enum:
185-
property.intValue = EditorGUILayout.Popup(property.enumValueIndex, property.enumNames, GUIL_StandartOptions);
186-
break;
187-
default:
188-
EditorGUILayout.PropertyField(property, GUIContent.none, true, GUIL_DefaultOptions);
189-
if (property.isExpanded)
190-
{
191-
float extraSpace = CalculatePropertyHeight(Configs, property);
192-
extraSpace -= EditorGUI.GetPropertyHeight(property);
193-
GUILayout.Space(extraSpace);
194-
}
195-
break;
196-
// Additional cases can be added here to support more property types
169+
float extraSpace = CalculatePropertyHeight(Configs, property);
170+
extraSpace -= EditorGUI.GetPropertyHeight(property);
171+
GUILayout.Space(extraSpace);
197172
}
198173
GUILayout.Space(PropertySpace);
199174
serializedObject.ApplyModifiedProperties();

Assets/Resources/ScriptableObjects/TestConfig.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ MonoBehaviour:
1515
number: -13
1616
value: 0
1717
text:
18-
flag: 0
18+
flag: 1
1919
position: {x: -3.8, y: 0, z: 12}
2020
rotation: {x: 0, y: 0, z: 0, w: 1}
2121
color: {r: 0.018718384, g: 0.90188676, b: 0.06520096, a: 1}

0 commit comments

Comments
 (0)