@@ -146,6 +146,9 @@ internal class PostprocessStack
146
146
internal ArrayList m_ImportProcessors = null ;
147
147
}
148
148
149
+ const string kCameraPostprocessorDependencyName = "postprocessor/camera" ;
150
+ const string kLightPostprocessorDependencyName = "postprocessor/light" ;
151
+
149
152
static ArrayList m_PostprocessStack = null ;
150
153
static ArrayList m_ImportProcessors = null ;
151
154
static Type [ ] m_PostprocessorClasses = null ;
@@ -154,6 +157,8 @@ internal class PostprocessStack
154
157
static string m_AudioProcessorsHashString = null ;
155
158
static string m_SpeedTreeProcessorsHashString = null ;
156
159
static string m_PrefabProcessorsHashString = null ;
160
+ static string m_CameraProcessorsHashString = null ;
161
+ static string m_LightProcessorsHashString = null ;
157
162
158
163
static Type [ ] GetCachedAssetPostprocessorClasses ( )
159
164
{
@@ -368,6 +373,22 @@ static void PostprocessMaterial(Material material)
368
373
CallPostProcessMethods ( "OnPostprocessMaterial" , args ) ;
369
374
}
370
375
376
+ [ RequiredByNativeCode ]
377
+ static void PreprocessCameraDescription ( AssetImportContext assetImportContext , CameraDescription description , Camera camera , AnimationClip [ ] animations )
378
+ {
379
+ assetImportContext . DependsOnCustomDependency ( kCameraPostprocessorDependencyName ) ;
380
+ object [ ] args = { description , camera , animations } ;
381
+ CallPostProcessMethods ( "OnPreprocessCameraDescription" , args ) ;
382
+ }
383
+
384
+ [ RequiredByNativeCode ]
385
+ static void PreprocessLightDescription ( AssetImportContext assetImportContext , LightDescription description , Light light , AnimationClip [ ] animations )
386
+ {
387
+ assetImportContext . DependsOnCustomDependency ( kLightPostprocessorDependencyName ) ;
388
+ object [ ] args = { description , light , animations } ;
389
+ CallPostProcessMethods ( "OnPreprocessLightDescription" , args ) ;
390
+ }
391
+
371
392
[ RequiredByNativeCode ]
372
393
static void PreprocessMaterialDescription ( MaterialDescription description , Material material , AnimationClip [ ] animations )
373
394
{
@@ -611,6 +632,58 @@ static string GetSpeedTreeProcessorsHashString()
611
632
return m_SpeedTreeProcessorsHashString ;
612
633
}
613
634
635
+ [ InitializeOnLoadMethod ]
636
+ static void RefreshCustomDependencies ( )
637
+ {
638
+ AssetDatabase . RegisterCustomDependency ( kCameraPostprocessorDependencyName , Hash128 . Compute ( GetCameraProcessorsHashString ( ) ) ) ;
639
+ AssetDatabase . RegisterCustomDependency ( kLightPostprocessorDependencyName , Hash128 . Compute ( GetLightProcessorsHashString ( ) ) ) ;
640
+ }
641
+
642
+ static void GetProcessorHashString ( string methodName , ref string hashString )
643
+ {
644
+ if ( hashString != null )
645
+ return ;
646
+
647
+ var versionsByType = new SortedList < string , uint > ( ) ;
648
+
649
+ foreach ( var assetPostprocessorClass in GetCachedAssetPostprocessorClasses ( ) )
650
+ {
651
+ try
652
+ {
653
+ if ( assetPostprocessorClass . GetMethod ( methodName , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) != null )
654
+ {
655
+ var inst = Activator . CreateInstance ( assetPostprocessorClass ) as AssetPostprocessor ;
656
+ uint version = inst . GetVersion ( ) ;
657
+ versionsByType . Add ( assetPostprocessorClass . FullName , version ) ;
658
+ }
659
+ }
660
+ catch ( MissingMethodException )
661
+ {
662
+ LogPostProcessorMissingDefaultConstructor ( assetPostprocessorClass ) ;
663
+ }
664
+ catch ( Exception e )
665
+ {
666
+ Debug . LogException ( e ) ;
667
+ }
668
+ }
669
+
670
+ hashString = BuildHashString ( versionsByType ) ;
671
+ }
672
+
673
+ [ RequiredByNativeCode ]
674
+ static string GetCameraProcessorsHashString ( )
675
+ {
676
+ GetProcessorHashString ( "OnPreprocessCameraDescription" , ref m_CameraProcessorsHashString ) ;
677
+ return m_CameraProcessorsHashString ;
678
+ }
679
+
680
+ [ RequiredByNativeCode ]
681
+ static string GetLightProcessorsHashString ( )
682
+ {
683
+ GetProcessorHashString ( "OnPreprocessLightDescription" , ref m_LightProcessorsHashString ) ;
684
+ return m_LightProcessorsHashString ;
685
+ }
686
+
614
687
static bool IsAssetPostprocessorAnalyticsEnabled ( )
615
688
{
616
689
return EditorAnalytics . enabled ;
0 commit comments