File tree Expand file tree Collapse file tree 2 files changed +23
-9
lines changed
com.unity.visualeffectgraph/Editor Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -28,8 +28,11 @@ void OnPreprocessAsset()
2828 VisualEffectResource resource = VisualEffectResource . GetResourceAtPath ( assetPath ) ;
2929 if ( resource == null )
3030 return ;
31-
32- resource . GetOrCreateGraph ( ) . SanitizeForImport ( ) ;
31+ VFXGraph graph = resource . graph as VFXGraph ;
32+ if ( graph != null )
33+ graph . SanitizeForImport ( ) ;
34+ else
35+ Debug . LogError ( "VisualEffectGraphResource without graph" ) ;
3336 }
3437 }
3538
@@ -38,9 +41,11 @@ static string[] OnAddResourceDependencies(string assetPath)
3841 VisualEffectResource resource = VisualEffectResource . GetResourceAtPath ( assetPath ) ;
3942 if ( resource != null )
4043 {
41- VFXGraph graph = resource . GetOrCreateGraph ( ) ;
44+ VFXGraph graph = resource . graph as VFXGraph ;
4245 if ( graph != null )
43- return graph . GetImportDependencies ( ) ;
46+ return resource . GetOrCreateGraph ( ) . GetImportDependencies ( ) ;
47+ else
48+ Debug . LogError ( "VisualEffectGraphResource without graph" ) ;
4449 }
4550 return null ;
4651 }
@@ -49,11 +54,11 @@ static void OnCompileResource(VisualEffectResource resource)
4954 {
5055 if ( resource != null )
5156 {
52- VFXGraph graph = resource . GetOrCreateGraph ( ) ;
57+ VFXGraph graph = resource . graph as VFXGraph ;
5358 if ( graph != null )
54- {
55- graph . CompileForImport ( ) ;
56- }
59+ resource . GetOrCreateGraph ( ) . CompileForImport ( ) ;
60+ else
61+ Debug . LogError ( "VisualEffectGraphResource without graph" ) ;
5762 }
5863 }
5964
Original file line number Diff line number Diff line change @@ -84,7 +84,16 @@ public static VisualEffectAsset CreateNewAsset(string path)
8484
8585 public static T CreateNew < T > ( string path ) where T : UnityObject
8686 {
87- string emptyAsset = "%YAML 1.1\n %TAG !u! tag:unity3d.com,2011:\n --- !u!2058629511 &1\n VisualEffectResource:\n " ;
87+ string emptyAsset =
88+ @"%YAML 1.1
89+ %TAG !u! tag:unity3d.com,2011:
90+ --- !u!114 &114350483966674976
91+ MonoBehaviour:
92+ m_Script: {fileID: 11500000, guid: 7d4c867f6b72b714dbb5fd1780afe208, type: 3}
93+ --- !u!2058629511 &1
94+ VisualEffectResource:
95+ m_Graph: {fileID: 114350483966674976}
96+ " ;
8897
8998 File . WriteAllText ( path , emptyAsset ) ;
9099
You can’t perform that action at this time.
0 commit comments