@@ -29,8 +29,7 @@ void IAssetPage.EventMouseDrag(in Event evt)
29
29
if ( Instance . ShowAssetDetail ) Instance . ViewDetailList . DraggingStretch ( evt , ViewRect . DragStretchType . Horizontal ) ;
30
30
}
31
31
32
- bool IAssetPage . Shortcut ( Event evt ) =>
33
- evt . control && evt . type == EventType . KeyDown && ( evt . keyCode == KeyCode . Keypad4 || evt . keyCode == KeyCode . Alpha4 ) ;
32
+ bool IAssetPage . Shortcut ( Event evt ) => evt . control && evt . type == EventType . KeyDown && ( evt . keyCode == KeyCode . Keypad4 || evt . keyCode == KeyCode . Alpha4 ) ;
34
33
35
34
public void Dispose ( )
36
35
{
@@ -50,52 +49,41 @@ public void Dispose()
50
49
private Dictionary < ( int , int ) , string [ ] > TagDisplays ;
51
50
private Dictionary < ( int , int ) , ConcurrentBag < AssetDataInfo > > DataDic ;
52
51
53
- public void OnDrawHeader ( Rect rect )
52
+ private Rect OnDrawGroup ( Rect rect )
54
53
{
55
- if ( Data . Packages . Length == 0 ||
56
- DisplayPackages is null ||
57
- DisplayPackages . Length == 0 ) return ;
58
-
59
- var width = rect . width ;
60
- rect . x = 0 ;
61
- rect . width = 100 ;
62
-
63
- EditorGUI . BeginChangeCheck ( ) ;
54
+ using var scope = new EditorGUI . ChangeCheckScope ( ) ;
64
55
Data . CurrentPackageIndex = EditorGUI . Popup ( rect , Data . CurrentPackageIndex , DisplayPackages , GEStyle . PreDropDown ) ;
65
56
66
- if ( ! Data . IsValidGroup ( ) ) return ;
57
+ if ( ! Data . IsValidGroup ( ) ) return rect ;
67
58
68
- var PName = DisplayPackages [ Data . CurrentPackageIndex ] ;
69
- if ( ! DisplayGroupNames . ContainsKey ( PName ) )
70
- DisplayGroupNames [ PName ] = GetGroupDisPlayNames ( Data . CurrentPackage . Groups ) ;
59
+ var package = DisplayPackages [ Data . CurrentPackageIndex ] ;
60
+ if ( ! DisplayGroupNames . ContainsKey ( package ) )
61
+ DisplayGroupNames [ package ] = GetGroupDisPlayNames ( Data . CurrentPackage . Groups ) ;
71
62
72
- if ( Data . CurrentGroupIndex >= DisplayGroupNames [ PName ] . Length )
73
- Data . CurrentGroupIndex = DisplayGroupNames [ PName ] . Length - 1 ;
63
+ if ( Data . CurrentGroupIndex >= DisplayGroupNames [ package ] . Length )
64
+ Data . CurrentGroupIndex = DisplayGroupNames [ package ] . Length - 1 ;
74
65
75
66
rect . x += rect . width ;
76
- Data . CurrentGroupIndex = EditorGUI . Popup ( rect , Data . CurrentGroupIndex , DisplayGroupNames [ PName ] , GEStyle . PreDropDown ) ;
67
+ Data . CurrentGroupIndex = EditorGUI . Popup ( rect , Data . CurrentGroupIndex , DisplayGroupNames [ package ] , GEStyle . PreDropDown ) ;
77
68
78
- if ( ! Data . IsValidCollect ( ) )
69
+ if ( ! Data . IsValidCollect ( ) || ! scope . changed ) return rect ;
70
+ if ( ! DataDic . ContainsKey ( ( Data . CurrentPackageIndex , Data . CurrentGroupIndex ) ) )
71
+ UpdateDataCollector ( Data . CurrentPackageIndex , Data . CurrentGroupIndex ) ;
72
+ else
79
73
{
80
- EditorGUI . EndChangeCheck ( ) ;
81
- return ;
74
+ PageValues . Clear ( ) ;
75
+ PageValues . Add ( DataDic [ ( Data . CurrentPackageIndex , Data . CurrentGroupIndex ) ] ) ;
76
+ PageValues . PageIndex = 0 ;
77
+ TreeViewQueryAsset . Reload ( PageValues ) ;
82
78
}
83
79
84
- if ( EditorGUI . EndChangeCheck ( ) )
85
- {
86
- if ( ! DataDic . ContainsKey ( ( Data . CurrentPackageIndex , Data . CurrentGroupIndex ) ) )
87
- UpdateDataCollector ( Data . CurrentPackageIndex , Data . CurrentGroupIndex ) ;
88
- else
89
- {
90
- PageValues . Clear ( ) ;
91
- PageValues . Add ( DataDic [ ( Data . CurrentPackageIndex , Data . CurrentGroupIndex ) ] ) ;
92
- PageValues . PageIndex = 0 ;
93
- TreeViewQueryAsset . Reload ( PageValues ) ;
94
- }
95
- }
80
+ return rect ;
81
+ }
96
82
97
- EditorGUI . BeginChangeCheck ( ) ;
98
- var collectors = CollectorDisplays [ ( Data . CurrentPackageIndex , Data . CurrentGroupIndex ) ] ;
83
+ private Rect OnDrawCollector ( Rect rect )
84
+ {
85
+ using var scope = new EditorGUI . ChangeCheckScope ( ) ;
86
+ var collectors = CollectorDisplays [ ( Data . CurrentPackageIndex , Data . CurrentGroupIndex ) ] ;
99
87
if ( collectors . Length > 0 )
100
88
{
101
89
rect . x += rect . width ;
@@ -151,18 +139,31 @@ DisplayPackages is null ||
151
139
}
152
140
else DisplayTagsIndex = 0 ;
153
141
154
- if ( EditorGUI . EndChangeCheck ( ) )
142
+ if ( ! scope . changed ) return rect ;
143
+ PageValues . Clear ( ) ;
144
+ lock ( DataDic )
155
145
{
156
- PageValues . Clear ( ) ;
157
- lock ( DataDic )
158
- {
159
- PageValues . Add ( DataDic [ ( Data . CurrentPackageIndex , Data . CurrentGroupIndex ) ] . Where ( data => ! FilterData ( data ) ) ) ;
160
- }
161
-
162
- PageValues . PageIndex = 0 ;
163
- TreeViewQueryAsset . Reload ( ) ;
146
+ PageValues . Add ( DataDic [ ( Data . CurrentPackageIndex , Data . CurrentGroupIndex ) ] . Where ( data => ! FilterData ( data ) ) ) ;
164
147
}
165
148
149
+ PageValues . PageIndex = 0 ;
150
+ TreeViewQueryAsset . Reload ( ) ;
151
+
152
+ return rect ;
153
+ }
154
+
155
+ public void OnDrawHeader ( Rect rect )
156
+ {
157
+ if ( Data . Packages . Length == 0 ||
158
+ DisplayPackages is null ||
159
+ DisplayPackages . Length == 0 ) return ;
160
+
161
+ var width = rect . width ;
162
+ rect . x = 0 ;
163
+ rect . width = 100 ;
164
+ rect = OnDrawGroup ( rect ) ;
165
+ rect = OnDrawCollector ( rect ) ;
166
+
166
167
rect . x += rect . width + 3 ;
167
168
rect . width = width - 30 - rect . x - ( PageValues . Count <= 0 ? 0 : 190 ) ;
168
169
SearchAssetText ( rect ) ;
@@ -173,6 +174,7 @@ DisplayPackages is null ||
173
174
174
175
rect . x = width - 30 ;
175
176
rect . width = 30 ;
177
+
176
178
if ( GUI . Button ( rect , Instance . GC_REFRESH , GEStyle . TEtoolbarbutton ) )
177
179
{
178
180
Instance . SelectAsset = null ;
@@ -346,4 +348,4 @@ public void OnDrawContent(Rect rect)
346
348
}
347
349
}
348
350
}
349
- }
351
+ }
0 commit comments