diff --git a/com.unity.shadergraph/CHANGELOG.md b/com.unity.shadergraph/CHANGELOG.md index 79ca08ff163..a485d89f130 100644 --- a/com.unity.shadergraph/CHANGELOG.md +++ b/com.unity.shadergraph/CHANGELOG.md @@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed a number of memory leaks that caused Shader Graph assets to stay in memory after closing the Shader Graph window. - You can now smoothly edit controls on the `Dielectric Specular` node. - Fixed Blackboard Properties to support scientific notation. +- Fixed a bug where warnings in the Shader Graph or Sub Graph were treated as errors. - Fixed a bug where the error `Output value 'vert' is not initialized` displayed on all PBR graphs in Universal. [1210710](https://issuetracker.unity3d.com/issues/output-value-vert-is-not-completely-initialized-error-is-thrown-when-pbr-graph-is-created-using-urp) - Fixed a bug where PBR and Unlit master nodes in Universal had Alpha Clipping enabled by default. - Fixed an issue in where analytics wasn't always working. diff --git a/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs b/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs index 2baded4327e..cb2fbc68f1a 100644 --- a/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs +++ b/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs @@ -163,7 +163,7 @@ internal static string GetShaderText(string path, out List messageList in messages.Values) + { + foreach(var message in messageList) + { + if(message.severity == ShaderCompilerMessageSeverity.Error) + { + return true; + } + } + } + } + return false; + } } } diff --git a/com.unity.shadergraph/Tests/Editor/UnitTests/MessageManagerTests.cs b/com.unity.shadergraph/Tests/Editor/UnitTests/MessageManagerTests.cs index 6fe54f4e1cf..8b258892130 100644 --- a/com.unity.shadergraph/Tests/Editor/UnitTests/MessageManagerTests.cs +++ b/com.unity.shadergraph/Tests/Editor/UnitTests/MessageManagerTests.cs @@ -286,6 +286,42 @@ public void ClearNodesFromProvider_LeavesOtherNodes() var ret = GetListFrom(m_ComplexMgr); Assert.AreEqual(3, ret.Find(kpv => kpv.Key.Equals(node1.guid)).Value.Count); } + + [Test] + public void ReportAnyErrors_EmptyManager() + { + var ret = m_EmptyMgr.AnyError(); + Assert.IsFalse(ret); + } + + [Test] + public void ReportAnyErrors_ComplexManager() + { + var ret = m_ComplexMgr.AnyError(); + Assert.IsTrue(ret); + } + + [Test] + public void ReportAnyErrors_EmptyManager_OnlyWarnings() + { + m_EmptyMgr.AddOrAppendError(p0, node0.guid, w0); + m_EmptyMgr.AddOrAppendError(p1, node1.guid, w1); + + var ret = m_EmptyMgr.AnyError(); + Assert.IsFalse(ret); + } + + [Test] + public void ReportAnyErrors_EmptyManager_ErrorOneProvider() + { + m_EmptyMgr.AddOrAppendError(p0, node0.guid, w0); + m_EmptyMgr.AddOrAppendError(p1, node1.guid, e1); + + var ret = m_EmptyMgr.AnyError(); + Assert.IsTrue(ret); + } + + } }