11
11
using UnityEditorInternal . VersionControl ;
12
12
using System . Linq ;
13
13
using System . Reflection ;
14
+ using UnityEditor . Profiling ;
14
15
using UnityEngine . Scripting . APIUpdating ;
15
16
16
17
namespace UnityEditor
@@ -100,14 +101,16 @@ static void OnWillCreateAsset(string path)
100
101
{
101
102
foreach ( var assetModificationProcessorClass in AssetModificationProcessors )
102
103
{
103
- MethodInfo method = assetModificationProcessorClass . GetMethod ( "OnWillCreateAsset" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
104
+ const string methodName = "OnWillCreateAsset" ;
105
+ MethodInfo method = assetModificationProcessorClass . GetMethod ( methodName , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
104
106
if ( method != null )
105
107
{
106
108
object [ ] args = { path } ;
107
109
if ( ! CheckArguments ( args , method ) )
108
110
continue ;
109
111
110
- method . Invoke ( null , args ) ;
112
+ using ( new EditorPerformanceMarker ( $ "{ assetModificationProcessorClass . Name } .{ methodName } ", assetModificationProcessorClass ) . Auto ( ) )
113
+ method . Invoke ( null , args ) ;
111
114
}
112
115
}
113
116
}
@@ -120,12 +123,14 @@ static void FileModeChanged(string[] assets, FileMode mode)
120
123
object [ ] args = { assets , mode } ;
121
124
foreach ( var type in AssetModificationProcessors )
122
125
{
123
- var method = type . GetMethod ( "FileModeChanged" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
126
+ const string methodName = "FileModeChanged" ;
127
+ var method = type . GetMethod ( methodName , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
124
128
if ( method == null )
125
129
continue ;
126
130
if ( ! CheckArgumentsAndReturnType ( args , method , typeof ( void ) ) )
127
131
continue ;
128
- method . Invoke ( null , args ) ;
132
+ using ( new EditorPerformanceMarker ( $ "{ type . Name } .{ methodName } ", type ) . Auto ( ) )
133
+ method . Invoke ( null , args ) ;
129
134
}
130
135
}
131
136
@@ -151,14 +156,17 @@ static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSav
151
156
152
157
foreach ( var assetModificationProcessorClass in AssetModificationProcessors )
153
158
{
154
- MethodInfo method = assetModificationProcessorClass . GetMethod ( "OnWillSaveAssets" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
159
+ const string methodName = "OnWillSaveAssets" ;
160
+ MethodInfo method = assetModificationProcessorClass . GetMethod ( methodName , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
155
161
if ( method != null )
156
162
{
157
163
object [ ] args = { assetsThatShouldBeSaved } ;
158
164
if ( ! CheckArguments ( args , method ) )
159
165
continue ;
160
166
161
- string [ ] result = ( string [ ] ) method . Invoke ( null , args ) ;
167
+ string [ ] result ;
168
+ using ( new EditorPerformanceMarker ( $ "{ assetModificationProcessorClass . Name } .{ methodName } ", assetModificationProcessorClass ) . Auto ( ) )
169
+ result = ( string [ ] ) method . Invoke ( null , args ) ;
162
170
163
171
if ( result != null )
164
172
assetsThatShouldBeSaved = result ;
@@ -195,14 +203,16 @@ static AssetMoveResult OnWillMoveAsset(string fromPath, string toPath, string[]
195
203
196
204
foreach ( var assetModificationProcessorClass in AssetModificationProcessors )
197
205
{
198
- MethodInfo method = assetModificationProcessorClass . GetMethod ( "OnWillMoveAsset" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
206
+ const string methodName = "OnWillMoveAsset" ;
207
+ MethodInfo method = assetModificationProcessorClass . GetMethod ( methodName , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
199
208
if ( method != null )
200
209
{
201
210
object [ ] args = { fromPath , toPath } ;
202
211
if ( ! CheckArgumentsAndReturnType ( args , method , finalResult . GetType ( ) ) )
203
212
continue ;
204
213
205
- finalResult |= ( AssetMoveResult ) method . Invoke ( null , args ) ;
214
+ using ( new EditorPerformanceMarker ( $ "{ assetModificationProcessorClass . Name } .{ methodName } ", assetModificationProcessorClass ) . Auto ( ) )
215
+ finalResult |= ( AssetMoveResult ) method . Invoke ( null , args ) ;
206
216
}
207
217
}
208
218
@@ -215,14 +225,16 @@ static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions
215
225
216
226
foreach ( var assetModificationProcessorClass in AssetModificationProcessors )
217
227
{
218
- MethodInfo method = assetModificationProcessorClass . GetMethod ( "OnWillDeleteAsset" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
228
+ const string methodName = "OnWillDeleteAsset" ;
229
+ MethodInfo method = assetModificationProcessorClass . GetMethod ( methodName , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
219
230
if ( method != null )
220
231
{
221
232
object [ ] args = { assetPath , options } ;
222
233
if ( ! CheckArgumentsAndReturnType ( args , method , finalResult . GetType ( ) ) )
223
234
continue ;
224
235
225
- finalResult |= ( AssetDeleteResult ) method . Invoke ( null , args ) ;
236
+ using ( new EditorPerformanceMarker ( $ "{ assetModificationProcessorClass . Name } .{ methodName } ", assetModificationProcessorClass ) . Auto ( ) )
237
+ finalResult |= ( AssetDeleteResult ) method . Invoke ( null , args ) ;
226
238
}
227
239
}
228
240
@@ -243,7 +255,8 @@ static void OnWillDeleteAssets(string[] assetPaths, AssetDeleteResult[] outPathD
243
255
List < int > nonDeletedPathIndices = new List < int > ( ) ;
244
256
foreach ( var assetModificationProcessorClass in AssetModificationProcessors )
245
257
{
246
- MethodInfo method = assetModificationProcessorClass . GetMethod ( "OnWillDeleteAsset" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
258
+ const string methodName = "OnWillDeleteAsset" ;
259
+ MethodInfo method = assetModificationProcessorClass . GetMethod ( methodName , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
247
260
if ( method == null )
248
261
continue ;
249
262
@@ -253,8 +266,12 @@ static void OnWillDeleteAssets(string[] assetPaths, AssetDeleteResult[] outPathD
253
266
if ( ! CheckArgumentsAndReturnType ( args , method , typeof ( AssetDeleteResult ) ) )
254
267
continue ;
255
268
256
- AssetDeleteResult callbackResult = ( AssetDeleteResult ) method . Invoke ( null , args ) ;
257
- outPathDeletionResults [ i ] |= callbackResult ;
269
+
270
+ using ( new EditorPerformanceMarker ( $ "{ assetModificationProcessorClass . Name } .{ methodName } ", assetModificationProcessorClass ) . Auto ( ) )
271
+ {
272
+ AssetDeleteResult callbackResult = ( AssetDeleteResult ) method . Invoke ( null , args ) ;
273
+ outPathDeletionResults [ i ] |= callbackResult ;
274
+ }
258
275
}
259
276
}
260
277
@@ -531,14 +548,16 @@ internal static void OnStatusUpdated()
531
548
532
549
foreach ( var assetModificationProcessorClass in AssetModificationProcessors )
533
550
{
534
- MethodInfo method = assetModificationProcessorClass . GetMethod ( "OnStatusUpdated" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
551
+ const string methodName = "OnStatusUpdated" ;
552
+ MethodInfo method = assetModificationProcessorClass . GetMethod ( methodName , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Static ) ;
535
553
if ( method != null )
536
554
{
537
555
object [ ] args = { } ;
538
556
if ( ! CheckArgumentsAndReturnType ( args , method , typeof ( void ) ) )
539
557
continue ;
540
558
541
- method . Invoke ( null , args ) ;
559
+ using ( new EditorPerformanceMarker ( $ "{ assetModificationProcessorClass . Name } .{ methodName } ", assetModificationProcessorClass ) . Auto ( ) )
560
+ method . Invoke ( null , args ) ;
542
561
}
543
562
}
544
563
}
0 commit comments