No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ShadowCasterGroup2D.cs 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System.Collections.Generic;
  2. using UnityEngine.Scripting.APIUpdating;
  3. namespace UnityEngine.Rendering.Universal
  4. {
  5. /// <summary>
  6. /// Class for 2D shadow caster groups.
  7. /// </summary>
  8. [MovedFrom(false, "UnityEngine.Experimental.Rendering.Universal", "com.unity.render-pipelines.universal")]
  9. public abstract class ShadowCasterGroup2D : MonoBehaviour
  10. {
  11. [SerializeField] internal int m_ShadowGroup = 0;
  12. [SerializeField] internal int m_Priority = 0;
  13. List<ShadowCaster2D> m_ShadowCasters;
  14. internal virtual void CacheValues()
  15. {
  16. if (m_ShadowCasters != null)
  17. {
  18. for (int i = 0; i < m_ShadowCasters.Count; i++)
  19. m_ShadowCasters[i].CacheValues();
  20. }
  21. }
  22. /// <summary>
  23. /// Returns a list of registered 2D shadow casters.
  24. /// </summary>
  25. /// <returns>A list of 2D shadow casters that have been registered..</returns>
  26. public List<ShadowCaster2D> GetShadowCasters()
  27. {
  28. return m_ShadowCasters;
  29. }
  30. /// <summary>
  31. /// Returns the shadow group.
  32. /// </summary>
  33. /// <returns>The shadow group used.</returns>
  34. public int GetShadowGroup()
  35. {
  36. return m_ShadowGroup;
  37. }
  38. /// <summary>
  39. /// Registers a 2D shadow caster.
  40. /// </summary>
  41. /// <param name="shadowCaster2D">The 2D shadow to register.</param>
  42. public void RegisterShadowCaster2D(ShadowCaster2D shadowCaster2D)
  43. {
  44. if (m_ShadowCasters == null)
  45. m_ShadowCasters = new List<ShadowCaster2D>();
  46. int insertAtIndex = 0;
  47. for (insertAtIndex = 0; insertAtIndex < m_ShadowCasters.Count; insertAtIndex++)
  48. {
  49. if (shadowCaster2D.m_Priority >= m_ShadowCasters[insertAtIndex].m_Priority)
  50. break;
  51. }
  52. m_ShadowCasters.Insert(insertAtIndex, shadowCaster2D);
  53. }
  54. /// <summary>
  55. /// Unregisters a 2D shadow caster.
  56. /// </summary>
  57. /// <param name="shadowCaster2D">The 2D shadow to unregister.</param>
  58. public void UnregisterShadowCaster2D(ShadowCaster2D shadowCaster2D)
  59. {
  60. if (m_ShadowCasters != null)
  61. m_ShadowCasters.Remove(shadowCaster2D);
  62. }
  63. }
  64. }