Skip to content

Commit c5ad428

Browse files
Improved SOs quick access tool
1 parent 16c4cbb commit c5ad428

File tree

1 file changed

+59
-42
lines changed

1 file changed

+59
-42
lines changed

UOP1_Project/Assets/Scripts/Editor/SOsQuickAccessToolWindow.cs

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,72 @@ private void OnEnable()
2525
{
2626
assetSearchFolders = new string[1];
2727
assetSearchFolders[0] = "Assets/ScriptableObjects";
28+
29+
FindAllSOs();
2830
}
2931

30-
[MenuItem("Tools/Quick Access Tool")]
32+
void OnFocus()
33+
{
34+
FindAllSOs();
35+
}
36+
37+
[MenuItem("Tools/SOs Quick Access Tool")]
3138
private static void ShowWindow()
3239
{
33-
GetWindow<SOsQuickAccessToolWindow>("Quick Access Tool");
40+
GetWindow<SOsQuickAccessToolWindow>("SOs Quick Access Tool");
3441
}
3542

3643
void OnGUI()
3744
{
38-
// All finding work #1
45+
GUILayout.Space(EditorGUIUtility.singleLineHeight);
46+
47+
if (GUILayout.Button("Refresh All"))
48+
{
49+
FindAllSOs();
50+
FindDisplaySOs();
51+
}
52+
53+
GUILayout.Space(EditorGUIUtility.singleLineHeight);
54+
GUILayout.Label("Please select a Scriptable Object Type To Search For");
55+
GUILayout.Space(EditorGUIUtility.singleLineHeight);
56+
DrawSOsPicker();
57+
58+
GUILayout.Space(EditorGUIUtility.singleLineHeight * 3f);
59+
DrawSOsList();
60+
}
61+
62+
void DrawSOsPicker()
63+
{
64+
EditorGUI.BeginChangeCheck();
65+
selected = EditorGUILayout.Popup("Scriptable Object Types", selected, SOTypes.ToArray());
66+
if (EditorGUI.EndChangeCheck())
67+
{
68+
FindDisplaySOs();
69+
}
70+
}
71+
72+
void DrawSOsList()
73+
{
74+
scroll = GUILayout.BeginScrollView(scroll);
75+
76+
for (int i=0; i< displayObjectsGUIDs.Length; i++)
77+
{
78+
GUILayout.Label(i+1 + ". " + displayObjects[i].name);
79+
80+
if (GUILayout.Button("Locate Quickly"))
81+
{
82+
EditorUtility.FocusProjectWindow();
83+
EditorGUIUtility.PingObject(displayObjects[i]);
84+
}
85+
86+
GUILayout.Space(EditorGUIUtility.singleLineHeight);
87+
}
88+
89+
GUILayout.EndScrollView();
90+
}
91+
92+
void FindAllSOs()
93+
{
3994
objectsGUIDs = AssetDatabase.FindAssets("t:ScriptableObject", assetSearchFolders) as string[];
4095

4196
objectsPaths = new string[objectsGUIDs.Length];
@@ -57,30 +112,9 @@ void OnGUI()
57112
SOTypes.Add(objects[i].GetType().ToString());
58113
}
59114
}
60-
// End #1
61-
62-
GUILayout.Space(EditorGUIUtility.singleLineHeight * 2f);
63-
64-
GUILayout.Label("Please select a Scriptable Object Type To Search For...");
65-
66-
GUILayout.Space(EditorGUIUtility.singleLineHeight);
67-
DrawSOsPicker();
68-
69-
GUILayout.Space(EditorGUIUtility.singleLineHeight * 3f);
70-
DrawSOsList();
71-
}
72-
73-
void DrawSOsPicker()
74-
{
75-
EditorGUI.BeginChangeCheck();
76-
selected = EditorGUILayout.Popup("Scriptable Object Types", selected, SOTypes.ToArray());
77-
if (EditorGUI.EndChangeCheck())
78-
{
79-
DrawSOsList();
80-
}
81115
}
82116

83-
void DrawSOsList()
117+
void FindDisplaySOs()
84118
{
85119
if (displayObjects != null)
86120
{
@@ -104,22 +138,5 @@ void DrawSOsList()
104138
displayObjectsPaths.Add(AssetDatabase.GUIDToAssetPath(displayObjectsGUIDs[i]));
105139
displayObjects.Add(AssetDatabase.LoadAssetAtPath(displayObjectsPaths[i], typeof(ScriptableObject)) as ScriptableObject);
106140
}
107-
108-
scroll = GUILayout.BeginScrollView(scroll);
109-
110-
for (int i=0; i< displayObjectsGUIDs.Length; i++)
111-
{
112-
GUILayout.Label(i+1 + ". " + displayObjects[i].name);
113-
114-
if (GUILayout.Button("Locate"))
115-
{
116-
EditorUtility.FocusProjectWindow();
117-
EditorGUIUtility.PingObject(displayObjects[i]);
118-
}
119-
120-
GUILayout.Space(EditorGUIUtility.singleLineHeight);
121-
}
122-
123-
GUILayout.EndScrollView();
124141
}
125142
}

0 commit comments

Comments
 (0)