Exemple #1
0
 public void OnAfterDeserialize()
 {
     // Upgrade from no serialized version
     if (m_ComponentVersion == ComponentVersions.Version_Unserialized)
     {
         ShadowUtility.ComputeBoundingSphere(m_ShapePath, out m_ProjectedBoundingSphere);
         m_ComponentVersion = ComponentVersions.Version_1;
     }
 }
Exemple #2
0
        protected void OnEnable()
        {
            if (m_Mesh == null || m_InstanceId != GetInstanceID())
            {
                m_Mesh = new Mesh();
                m_ProjectedBoundingSphere = ShadowUtility.GenerateShadowMesh(m_Mesh, m_ShapePath);
                m_InstanceId = GetInstanceID();
            }

            m_ShadowCasterGroup = null;
        }
Exemple #3
0
        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);
                }
            }
        }