public void Update() { if (player != null && Vector2.Distance(this.transform.position, player.transform.position) > 8) { return; } Renderer renderer = GetComponent <Renderer>(); m_HasRenderer = renderer != null; bool rebuildMesh = LightUtility.CheckForChange(m_ShapePathHash, ref m_PreviousPathHash); if (rebuildMesh) { 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); } } }
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.RemoveFromShadowCasterGroup(this, m_ShadowCasterGroup); }