public void Update() { Renderer renderer; m_HasRenderer = TryGetComponent <Renderer>(out renderer); bool rebuildMesh = LightUtility.CheckForChange(m_ShapePathHash, ref m_PreviousPathHash); if (rebuildMesh) { m_ProjectedBoundingSphere = ShadowUtility.GenerateShadowMesh(m_Mesh, m_ShapePath); } m_PreviousShadowCasterGroup = m_ShadowCasterGroup; bool addedToNewGroup = ShadowCasterGroup2DManager.AddToShadowCasterGroup(this, ref m_ShadowCasterGroup); if (addedToNewGroup && m_ShadowCasterGroup != null) { if (m_PreviousShadowCasterGroup == this) { ShadowCasterGroup2DManager.RemoveGroup(this); } ShadowCasterGroup2DManager.RemoveFromShadowCasterGroup(this, m_PreviousShadowCasterGroup); if (m_ShadowCasterGroup == this) { ShadowCasterGroup2DManager.AddGroup(this); } } if (LightUtility.CheckForChange(m_ShadowGroup, ref m_PreviousShadowGroup)) { ShadowCasterGroup2DManager.RemoveGroup(this); ShadowCasterGroup2DManager.AddGroup(this); } if (LightUtility.CheckForChange(m_CastsShadows, ref m_PreviousCastsShadows)) { if (m_CastsShadows) { ShadowCasterGroup2DManager.AddGroup(this); } else { ShadowCasterGroup2DManager.RemoveGroup(this); } } }
protected void OnDisable() { ShadowCasterGroup2DManager.RemoveGroup(this); }