public static void RemoveGroup(ShadowCasterGroup2D group)
 {
     if (group != null && s_ShadowCasterGroups != null)
     {
         RemoveShadowCasterGroupFromList(group, s_ShadowCasterGroups);
     }
 }
 public static void RemoveFromShadowCasterGroup(ShadowCaster2D shadowCaster, ShadowCasterGroup2D shadowCasterGroup)
 {
     if (shadowCasterGroup != null)
     {
         shadowCasterGroup.UnregisterShadowCaster2D(shadowCaster);
     }
 }
예제 #3
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;
        }
        public static void AddGroup(ShadowCasterGroup2D group)
        {
            if (group == null)
            {
                return;
            }

            if (s_ShadowCasterGroups == null)
            {
                s_ShadowCasterGroups = new List <ShadowCasterGroup2D>();
            }

            AddShadowCasterGroupToList(group, s_ShadowCasterGroups);
        }
        public static void AddShadowCasterGroupToList(ShadowCasterGroup2D shadowCaster, List <ShadowCasterGroup2D> list)
        {
            int positionToInsert = 0;

            for (positionToInsert = 0; positionToInsert < list.Count; positionToInsert++)
            {
                if (shadowCaster.GetShadowGroup() == list[positionToInsert].GetShadowGroup())
                {
                    break;
                }
            }

            list.Insert(positionToInsert, shadowCaster);
        }
예제 #6
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);
                }
            }
        }
        public static bool AddToShadowCasterGroup(ShadowCaster2D shadowCaster, ref ShadowCasterGroup2D shadowCasterGroup)
        {
            ShadowCasterGroup2D newShadowCasterGroup = FindTopMostCompositeShadowCaster(shadowCaster) as ShadowCasterGroup2D;

            if (newShadowCasterGroup == null)
            {
                newShadowCasterGroup = shadowCaster.GetComponent <ShadowCaster2D>();
            }

            if (newShadowCasterGroup != null && shadowCasterGroup != newShadowCasterGroup)
            {
                newShadowCasterGroup.RegisterShadowCaster2D(shadowCaster);
                shadowCasterGroup = newShadowCasterGroup;
                return(true);
            }

            return(false);
        }
 public static void RemoveShadowCasterGroupFromList(ShadowCasterGroup2D shadowCaster, List <ShadowCasterGroup2D> list)
 {
     list.Remove(shadowCaster);
 }