Skip to content

Commit 2281eb8

Browse files
committed
make variant importer use absolute and relative paths
1 parent 9621ffd commit 2281eb8

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

Editor/Importer/VariantImporter.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Shaders/Toon Outline.graphlitvariant.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)