diff --git a/com.unity.shadergraph/CHANGELOG.md b/com.unity.shadergraph/CHANGELOG.md index 91fae3ebae2..7da74cecc75 100644 --- a/com.unity.shadergraph/CHANGELOG.md +++ b/com.unity.shadergraph/CHANGELOG.md @@ -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. diff --git a/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs b/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs index 2da03f02dd2..7ee5a04222b 100644 --- a/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs +++ b/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs @@ -147,6 +147,13 @@ public override void OnImportAsset(AssetImportContext ctx) { metadata.outputNodeTypeName = graph.outputNode.GetType().FullName; } + metadata.assetDependencies = new List(); + 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()) diff --git a/com.unity.shadergraph/Editor/Importers/ShaderGraphMetadata.cs b/com.unity.shadergraph/Editor/Importers/ShaderGraphMetadata.cs index 95815486036..5b548191251 100644 --- a/com.unity.shadergraph/Editor/Importers/ShaderGraphMetadata.cs +++ b/com.unity.shadergraph/Editor/Importers/ShaderGraphMetadata.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using UnityEngine; namespace UnityEditor.ShaderGraph @@ -5,5 +6,6 @@ namespace UnityEditor.ShaderGraph class ShaderGraphMetadata : ScriptableObject { public string outputNodeTypeName; + public List assetDependencies; } } diff --git a/com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporter.cs b/com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporter.cs index 449b4c9845f..415232bb142 100644 --- a/com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporter.cs +++ b/com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporter.cs @@ -76,6 +76,16 @@ public override void OnImportAsset(AssetImportContext ctx) Texture2D texture = Resources.Load("Icons/sg_subgraph_icon@64"); ctx.AddObjectToAsset("MainAsset", graphAsset, texture); ctx.SetMainObject(graphAsset); + + var metadata = ScriptableObject.CreateInstance(); + metadata.hideFlags = HideFlags.HideInHierarchy; + metadata.assetDependencies = new List(); + 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) diff --git a/com.unity.shadergraph/Editor/Importers/ShaderSubGraphMetadata.cs b/com.unity.shadergraph/Editor/Importers/ShaderSubGraphMetadata.cs new file mode 100644 index 00000000000..ccea2bd6844 --- /dev/null +++ b/com.unity.shadergraph/Editor/Importers/ShaderSubGraphMetadata.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UnityEditor.ShaderGraph +{ + class ShaderSubGraphMetadata : ScriptableObject + { + public List assetDependencies; + } +} diff --git a/com.unity.shadergraph/Editor/Importers/ShaderSubGraphMetadata.cs.meta b/com.unity.shadergraph/Editor/Importers/ShaderSubGraphMetadata.cs.meta new file mode 100644 index 00000000000..c3cc1d3c6c7 --- /dev/null +++ b/com.unity.shadergraph/Editor/Importers/ShaderSubGraphMetadata.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0169c6aa153625741a0b332e73a43fb2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: