Skip to content

Sg/export dependencies #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.shadergraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed a compilation error when using Hybrid Renderer due to incorrect positioning of macros.
- Fixed a bug where the `Create Node Menu` lagged on load. Entries are now only generated when property, keyword, or subgraph changes are detected. [1209567](https://issuetracker.unity3d.com/issues/shadergraph-opening-node-search-window-is-unnecessarily-slow).
- Fixed a bug with the `Transform` node where converting from `Absolute World` space in a sub graph causes invalid subscript errors. [1190813](https://issuetracker.unity3d.com/issues/shadergraph-invalid-subscript-errors-are-thrown-when-connecting-a-subgraph-with-transform-node-with-unlit-master-node)
- Fixed a bug where depndencies were not getting included when exporting a shadergraph and subgraphs
- Fixed a bug where adding a " to a property display name would cause shader compilation errors and show all nodes as broken
- Fixed a bug where the `Position` node would change coordinate spaces from `World` to `Absolute World` when shaders recompile. [1184617](https://issuetracker.unity3d.com/product/unity/issues/guid/1184617/)
- Fixed a bug where instanced shaders wouldn't compile on PS4.
Expand Down
7 changes: 7 additions & 0 deletions com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ public override void OnImportAsset(AssetImportContext ctx)
{
metadata.outputNodeTypeName = graph.outputNode.GetType().FullName;
}
metadata.assetDependencies = new List<UnityEngine.Object>();
var deps = GatherDependenciesFromSourceFile(ctx.assetPath);
foreach (string dependency in deps)
{
metadata.assetDependencies.Add(AssetDatabase.LoadAssetAtPath(dependency, typeof(UnityEngine.Object)));
}

ctx.AddObjectToAsset("Metadata", metadata);

foreach (var sourceAssetDependencyPath in sourceAssetDependencyPaths.Distinct())
Expand Down
2 changes: 2 additions & 0 deletions com.unity.shadergraph/Editor/Importers/ShaderGraphMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using UnityEngine;

namespace UnityEditor.ShaderGraph
{
class ShaderGraphMetadata : ScriptableObject
{
public string outputNodeTypeName;
public List<Object> assetDependencies;
}
}
10 changes: 10 additions & 0 deletions com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ public override void OnImportAsset(AssetImportContext ctx)
Texture2D texture = Resources.Load<Texture2D>("Icons/sg_subgraph_icon@64");
ctx.AddObjectToAsset("MainAsset", graphAsset, texture);
ctx.SetMainObject(graphAsset);

var metadata = ScriptableObject.CreateInstance<ShaderSubGraphMetadata>();
metadata.hideFlags = HideFlags.HideInHierarchy;
metadata.assetDependencies = new List<UnityEngine.Object>();
var deps = GatherDependenciesFromSourceFile(ctx.assetPath);
foreach (string dependency in deps)
{
metadata.assetDependencies.Add(AssetDatabase.LoadAssetAtPath(dependency, typeof(UnityEngine.Object)));
}
ctx.AddObjectToAsset("Metadata", metadata);
}

static void ProcessSubGraph(SubGraphAsset asset, GraphData graph)
Expand Down
10 changes: 10 additions & 0 deletions com.unity.shadergraph/Editor/Importers/ShaderSubGraphMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;
using UnityEngine;

namespace UnityEditor.ShaderGraph
{
class ShaderSubGraphMetadata : ScriptableObject
{
public List<Object> assetDependencies;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.