@@ -9,28 +9,38 @@ namespace Graphlit
99 [ ScriptedImporter ( 1 , new [ ] { "graphlitvariant" } , - 1 ) ]
1010 public class VariantImporter : ScriptedImporter
1111 {
12- [ SerializeField ] public string graphRelativePath = "" ;
13- [ SerializeField ] public string nameSuffix = "Variant" ;
12+ [ SerializeField ] [ Tooltip ( "Relative or Absolute Path to the Graphlit asset" ) ] public string graphPath = "" ;
1413 [ SerializeField ] public OutlinePassMode outlinePass = OutlinePassMode . Disabled ;
1514 [ SerializeField ] public bool depthFillPass = false ;
15+ [ SerializeField ] public string nameSuffix = "Variant" ;
1616
1717 internal void OverrideVariantData ( GraphData data )
1818 {
1919 data . shaderName += " " + nameSuffix ;
2020 data . outlinePass = outlinePass ;
2121 data . depthFillPass = depthFillPass ;
22+
23+ Debug . Log ( data . shaderName ) ;
2224 }
2325
2426 public override void OnImportAsset ( AssetImportContext ctx )
2527 {
2628 var target = ctx . selectedBuildTarget ;
27-
2829 string assetPath = "Packages/com.z3y.graphlit/Shaders/Unlit.graphlit" ;
2930
30- if ( ! string . IsNullOrEmpty ( graphRelativePath ) )
31+ if ( ! string . IsNullOrEmpty ( graphPath ) )
3132 {
32- var dir = Path . GetDirectoryName ( ctx . assetPath ) ;
33- assetPath = Path . Combine ( dir , graphRelativePath ) + ".graphlit" ;
33+ bool isAbsolute = graphPath . StartsWith ( "Assets/" ) || graphPath . StartsWith ( "Packages/" ) ;
34+ if ( isAbsolute )
35+ {
36+ assetPath = graphPath ;
37+ }
38+ else
39+ {
40+ var dir = Path . GetDirectoryName ( ctx . assetPath ) ;
41+ assetPath = Path . Combine ( dir , graphPath ) + ".graphlit" ;
42+ }
43+ ctx . DependsOnSourceAsset ( assetPath ) ;
3444 }
3545 string guid = AssetDatabase . AssetPathToGUID ( assetPath ) ;
3646
0 commit comments