@@ -25,17 +25,72 @@ private void OnEnable()
25
25
{
26
26
assetSearchFolders = new string [ 1 ] ;
27
27
assetSearchFolders [ 0 ] = "Assets/ScriptableObjects" ;
28
+
29
+ FindAllSOs ( ) ;
28
30
}
29
31
30
- [ MenuItem ( "Tools/Quick Access Tool" ) ]
32
+ void OnFocus ( )
33
+ {
34
+ FindAllSOs ( ) ;
35
+ }
36
+
37
+ [ MenuItem ( "Tools/SOs Quick Access Tool" ) ]
31
38
private static void ShowWindow ( )
32
39
{
33
- GetWindow < SOsQuickAccessToolWindow > ( "Quick Access Tool" ) ;
40
+ GetWindow < SOsQuickAccessToolWindow > ( "SOs Quick Access Tool" ) ;
34
41
}
35
42
36
43
void OnGUI ( )
37
44
{
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
+ {
39
94
objectsGUIDs = AssetDatabase . FindAssets ( "t:ScriptableObject" , assetSearchFolders ) as string [ ] ;
40
95
41
96
objectsPaths = new string [ objectsGUIDs . Length ] ;
@@ -57,30 +112,9 @@ void OnGUI()
57
112
SOTypes . Add ( objects [ i ] . GetType ( ) . ToString ( ) ) ;
58
113
}
59
114
}
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
- }
81
115
}
82
116
83
- void DrawSOsList ( )
117
+ void FindDisplaySOs ( )
84
118
{
85
119
if ( displayObjects != null )
86
120
{
@@ -104,22 +138,5 @@ void DrawSOsList()
104
138
displayObjectsPaths . Add ( AssetDatabase . GUIDToAssetPath ( displayObjectsGUIDs [ i ] ) ) ;
105
139
displayObjects . Add ( AssetDatabase . LoadAssetAtPath ( displayObjectsPaths [ i ] , typeof ( ScriptableObject ) ) as ScriptableObject ) ;
106
140
}
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 ( ) ;
124
141
}
125
142
}
0 commit comments