static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { foreach (var assetPath in deletedAssets) { if (VisualEffectAssetModicationProcessor.HasVFXExtension(assetPath)) { VisualEffectResource.DeleteAtPath(assetPath); } } if (!allowExternalization) { return; } HashSet <string> vfxToRefresh = new HashSet <string>(); HashSet <string> vfxToRecompile = new HashSet <string>(); // Recompile vfx if a shader is deleted to replace foreach (string assetPath in importedAssets.Concat(deletedAssets).Concat(movedAssets)) { if (assetPath.EndsWith(k_ShaderExt)) { string shaderDirectory = Path.GetDirectoryName(assetPath); string vfxName = Path.GetFileName(shaderDirectory); string vfxPath = Path.GetDirectoryName(shaderDirectory); if (Path.GetFileName(vfxPath) != k_ShaderDirectory) { continue; } vfxPath = Path.GetDirectoryName(vfxPath) + "/" + vfxName + VisualEffectResource.Extension; if (deletedAssets.Contains(assetPath)) { vfxToRecompile.Add(vfxPath); } else { vfxToRefresh.Add(vfxPath); } } } foreach (var assetPath in vfxToRecompile) { VisualEffectAsset asset = AssetDatabase.LoadAssetAtPath <VisualEffectAsset>(assetPath); if (asset == null) { continue; } // Force Recompilation to restore the previous shaders VisualEffectResource resource = asset.GetResource(); if (resource == null) { continue; } resource.GetOrCreateGraph().SetExpressionGraphDirty(); resource.GetOrCreateGraph().RecompileIfNeeded(false, true); } foreach (var assetPath in vfxToRefresh) { VisualEffectAsset asset = AssetDatabase.LoadAssetAtPath <VisualEffectAsset>(assetPath); if (asset == null) { return; } AssetDatabase.ImportAsset(assetPath); } }