Skip to content

Commit 384c47b

Browse files
Esmeralda SalamoneEvergreen
authored andcommitted
[ShaderGraph][Universal] Fix an NRE for URP sub-datas.
Added some null checks for SG serialization objects used by Universal Target. Also cleaned up the error messaging, which isn't useful or actionable to users in this circumstance.
1 parent 4bcb19f commit 384c47b

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTarget.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,9 @@ void ClearUnusedData()
694694
for (int i = 0; i < m_Datas.Count; i++)
695695
{
696696
var data = m_Datas[i];
697+
if (data.value is null)
698+
continue;
699+
697700
var type = data.value.GetType();
698701

699702
// Data requirement interfaces need generic type arguments
@@ -710,7 +713,17 @@ public void SetDataOnSubTarget<T>(SubTarget subTarget) where T : JsonObject
710713
return;
711714

712715
// Ensure data object exists in list
713-
var data = m_Datas.SelectValue().FirstOrDefault(x => x.GetType().Equals(typeof(T))) as T;
716+
717+
T data = null;
718+
foreach (var x in m_Datas.SelectValue())
719+
{
720+
if (x.GetType().Equals(typeof(T)))
721+
{
722+
data = x as T;
723+
continue;
724+
}
725+
}
726+
714727
if (data == null)
715728
{
716729
data = Activator.CreateInstance(typeof(T)) as T;

Packages/com.unity.shadergraph/Editor/Resources/Styles/HelpBoxRow.uss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ HelpBoxRow
3636

3737
.help-box-row-style-warning
3838
{
39-
background-color: #fcd76e;
4039
}
4140

4241
.help-box-row-style-warning #label
@@ -46,7 +45,6 @@ HelpBoxRow
4645

4746
.help-box-row-style-error
4847
{
49-
background-color: #fc6e6e;
5048
}
5149

5250
.help-box-row-style-error #label

Packages/com.unity.shadergraph/Editor/Serialization/JsonData.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public void OnAfterDeserialize()
3939
}
4040
else
4141
{
42-
Debug.LogError($"Missing {typeof(T).FullName} {m_Id}");
4342
}
4443
}
4544
catch (Exception e)

0 commit comments

Comments
 (0)