@@ -146,6 +146,9 @@ internal class PostprocessStack
146146 internal ArrayList m_ImportProcessors = null ;
147147 }
148148
149+ const string kCameraPostprocessorDependencyName = "postprocessor/camera" ;
150+ const string kLightPostprocessorDependencyName = "postprocessor/light" ;
151+
149152 static ArrayList m_PostprocessStack = null ;
150153 static ArrayList m_ImportProcessors = null ;
151154 static Type [ ] m_PostprocessorClasses = null ;
@@ -154,6 +157,8 @@ internal class PostprocessStack
154157 static string m_AudioProcessorsHashString = null ;
155158 static string m_SpeedTreeProcessorsHashString = null ;
156159 static string m_PrefabProcessorsHashString = null ;
160+ static string m_CameraProcessorsHashString = null ;
161+ static string m_LightProcessorsHashString = null ;
157162
158163 static Type [ ] GetCachedAssetPostprocessorClasses ( )
159164 {
@@ -368,6 +373,22 @@ static void PostprocessMaterial(Material material)
368373 CallPostProcessMethods ( "OnPostprocessMaterial" , args ) ;
369374 }
370375
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+
371392 [ RequiredByNativeCode ]
372393 static void PreprocessMaterialDescription ( MaterialDescription description , Material material , AnimationClip [ ] animations )
373394 {
@@ -611,6 +632,58 @@ static string GetSpeedTreeProcessorsHashString()
611632 return m_SpeedTreeProcessorsHashString ;
612633 }
613634
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+
614687 static bool IsAssetPostprocessorAnalyticsEnabled ( )
615688 {
616689 return EditorAnalytics . enabled ;
0 commit comments