Skip to content

Commit c23de1c

Browse files
ApoorvaJEvergreen
authored andcommitted
Fix error when entering Play Mode with PBR Sky Shader Graph
1 parent 42fb506 commit c23de1c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Packages/com.unity.shadergraph/Editor/Data/Graphs/SerializableCubemap.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ public Cubemap cubemap
9292

9393
public void OnBeforeSerialize()
9494
{
95-
m_SerializedCubemap = EditorJsonUtility.ToJson(new CubemapHelper { cubemap = cubemap }, false);
95+
// If m_Cubemap is null, the data is still in serialized form
96+
// (m_SerializedCubemap or m_Guid) and doesn't need to be re-serialized.
97+
// We must not use the cubemap property getter here because it would
98+
// force-load the asset, which is not safe in all contexts (e.g. domain backup).
99+
if (m_Cubemap != null)
100+
m_SerializedCubemap = EditorJsonUtility.ToJson(new CubemapHelper { cubemap = m_Cubemap }, false);
96101
}
97102

98103
public void OnAfterDeserialize()

0 commit comments

Comments
 (0)