using System.Collections.Generic; using UnityEngine.Scripting.APIUpdating; namespace UnityEngine.Rendering.Universal { /// /// Class for 2D shadow caster groups. /// [MovedFrom(false, "UnityEngine.Experimental.Rendering.Universal", "com.unity.render-pipelines.universal")] public abstract class ShadowCasterGroup2D : MonoBehaviour { [SerializeField] internal int m_ShadowGroup = 0; [SerializeField] internal int m_Priority = 0; List m_ShadowCasters; internal virtual void CacheValues() { if (m_ShadowCasters != null) { for (int i = 0; i < m_ShadowCasters.Count; i++) m_ShadowCasters[i].CacheValues(); } } /// /// Returns a list of registered 2D shadow casters. /// /// A list of 2D shadow casters that have been registered.. public List GetShadowCasters() { return m_ShadowCasters; } /// /// Returns the shadow group. /// /// The shadow group used. public int GetShadowGroup() { return m_ShadowGroup; } /// /// Registers a 2D shadow caster. /// /// The 2D shadow to register. public void RegisterShadowCaster2D(ShadowCaster2D shadowCaster2D) { if (m_ShadowCasters == null) m_ShadowCasters = new List(); int insertAtIndex = 0; for (insertAtIndex = 0; insertAtIndex < m_ShadowCasters.Count; insertAtIndex++) { if (shadowCaster2D.m_Priority >= m_ShadowCasters[insertAtIndex].m_Priority) break; } m_ShadowCasters.Insert(insertAtIndex, shadowCaster2D); } /// /// Unregisters a 2D shadow caster. /// /// The 2D shadow to unregister. public void UnregisterShadowCaster2D(ShadowCaster2D shadowCaster2D) { if (m_ShadowCasters != null) m_ShadowCasters.Remove(shadowCaster2D); } } }