1111using UnityEditorInternal . VersionControl ;
1212using System . Linq ;
1313using System . Reflection ;
14+ using UnityEditor . Profiling ;
1415using UnityEngine . Scripting . APIUpdating ;
1516
1617namespace UnityEditor
@@ -100,14 +101,16 @@ static void OnWillCreateAsset(string path)
100101 {
101102 foreach ( var assetModificationProcessorClass in AssetModificationProcessors )
102103 {
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 ) ;
104106 if ( method != null )
105107 {
106108 object [ ] args = { path } ;
107109 if ( ! CheckArguments ( args , method ) )
108110 continue ;
109111
110- method . Invoke ( null , args ) ;
112+ using ( new EditorPerformanceMarker ( $ "{ assetModificationProcessorClass . Name } .{ methodName } ", assetModificationProcessorClass ) . Auto ( ) )
113+ method . Invoke ( null , args ) ;
111114 }
112115 }
113116 }
@@ -120,12 +123,14 @@ static void FileModeChanged(string[] assets, FileMode mode)
120123 object [ ] args = { assets , mode } ;
121124 foreach ( var type in AssetModificationProcessors )
122125 {
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 ) ;
124128 if ( method == null )
125129 continue ;
126130 if ( ! CheckArgumentsAndReturnType ( args , method , typeof ( void ) ) )
127131 continue ;
128- method . Invoke ( null , args ) ;
132+ using ( new EditorPerformanceMarker ( $ "{ type . Name } .{ methodName } ", type ) . Auto ( ) )
133+ method . Invoke ( null , args ) ;
129134 }
130135 }
131136
@@ -151,14 +156,17 @@ static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSav
151156
152157 foreach ( var assetModificationProcessorClass in AssetModificationProcessors )
153158 {
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 ) ;
155161 if ( method != null )
156162 {
157163 object [ ] args = { assetsThatShouldBeSaved } ;
158164 if ( ! CheckArguments ( args , method ) )
159165 continue ;
160166
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 ) ;
162170
163171 if ( result != null )
164172 assetsThatShouldBeSaved = result ;
@@ -195,14 +203,16 @@ static AssetMoveResult OnWillMoveAsset(string fromPath, string toPath, string[]
195203
196204 foreach ( var assetModificationProcessorClass in AssetModificationProcessors )
197205 {
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 ) ;
199208 if ( method != null )
200209 {
201210 object [ ] args = { fromPath , toPath } ;
202211 if ( ! CheckArgumentsAndReturnType ( args , method , finalResult . GetType ( ) ) )
203212 continue ;
204213
205- finalResult |= ( AssetMoveResult ) method . Invoke ( null , args ) ;
214+ using ( new EditorPerformanceMarker ( $ "{ assetModificationProcessorClass . Name } .{ methodName } ", assetModificationProcessorClass ) . Auto ( ) )
215+ finalResult |= ( AssetMoveResult ) method . Invoke ( null , args ) ;
206216 }
207217 }
208218
@@ -215,14 +225,16 @@ static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions
215225
216226 foreach ( var assetModificationProcessorClass in AssetModificationProcessors )
217227 {
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 ) ;
219230 if ( method != null )
220231 {
221232 object [ ] args = { assetPath , options } ;
222233 if ( ! CheckArgumentsAndReturnType ( args , method , finalResult . GetType ( ) ) )
223234 continue ;
224235
225- finalResult |= ( AssetDeleteResult ) method . Invoke ( null , args ) ;
236+ using ( new EditorPerformanceMarker ( $ "{ assetModificationProcessorClass . Name } .{ methodName } ", assetModificationProcessorClass ) . Auto ( ) )
237+ finalResult |= ( AssetDeleteResult ) method . Invoke ( null , args ) ;
226238 }
227239 }
228240
@@ -243,7 +255,8 @@ static void OnWillDeleteAssets(string[] assetPaths, AssetDeleteResult[] outPathD
243255 List < int > nonDeletedPathIndices = new List < int > ( ) ;
244256 foreach ( var assetModificationProcessorClass in AssetModificationProcessors )
245257 {
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 ) ;
247260 if ( method == null )
248261 continue ;
249262
@@ -253,8 +266,12 @@ static void OnWillDeleteAssets(string[] assetPaths, AssetDeleteResult[] outPathD
253266 if ( ! CheckArgumentsAndReturnType ( args , method , typeof ( AssetDeleteResult ) ) )
254267 continue ;
255268
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+ }
258275 }
259276 }
260277
@@ -531,14 +548,16 @@ internal static void OnStatusUpdated()
531548
532549 foreach ( var assetModificationProcessorClass in AssetModificationProcessors )
533550 {
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 ) ;
535553 if ( method != null )
536554 {
537555 object [ ] args = { } ;
538556 if ( ! CheckArgumentsAndReturnType ( args , method , typeof ( void ) ) )
539557 continue ;
540558
541- method . Invoke ( null , args ) ;
559+ using ( new EditorPerformanceMarker ( $ "{ assetModificationProcessorClass . Name } .{ methodName } ", assetModificationProcessorClass ) . Auto ( ) )
560+ method . Invoke ( null , args ) ;
542561 }
543562 }
544563 }
0 commit comments