Skip to content

Commit b439562

Browse files
committed
Added versioning code for ShadowCaster2D
1 parent 91f7f80 commit b439562

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowCaster2D.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ namespace UnityEngine.Experimental.Rendering.Universal
1313
[AddComponentMenu("Rendering/2D/Shadow Caster 2D (Experimental)")]
1414
public class ShadowCaster2D : ShadowCasterGroup2D
1515
{
16+
const int k_CurrentVersion = 1;
17+
[SerializeField] int m_Version = 0;
18+
1619
[SerializeField] bool m_HasRenderer = false;
1720
[SerializeField] bool m_UseRendererSilhouette = true;
1821
[SerializeField] bool m_CastsShadows = true;
@@ -22,6 +25,7 @@ public class ShadowCaster2D : ShadowCasterGroup2D
2225
[SerializeField] int m_ShapePathHash = 0;
2326
[SerializeField] Mesh m_Mesh;
2427
[SerializeField] int m_InstanceId;
28+
2529

2630
internal ShadowCasterGroup2D m_ShadowCasterGroup = null;
2731
internal ShadowCasterGroup2D m_PreviousShadowCasterGroup = null;
@@ -132,11 +136,12 @@ private void Awake()
132136

133137
protected void OnEnable()
134138
{
135-
if (m_Mesh == null || m_InstanceId != GetInstanceID())
139+
if (m_Mesh == null || m_InstanceId != GetInstanceID() || m_Version != k_CurrentVersion)
136140
{
137141
m_Mesh = new Mesh();
138142
m_ProjectedBoundingSphere = ShadowUtility.GenerateShadowMesh(m_Mesh, m_ShapePath);
139143
m_InstanceId = GetInstanceID();
144+
m_Version = k_CurrentVersion;
140145
}
141146

142147
m_ShadowCasterGroup = null;

0 commit comments

Comments
 (0)