ParticleLODService.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /// <summary>
  5. /// 粒子系统LOD管理器
  6. /// </summary>
  7. public class ParticleLODService : PoolObject
  8. {
  9. public Transform m_LOD_1;
  10. public Transform m_LOD_2;
  11. public Transform m_LOD_3;
  12. #if UNITY_EDITOR
  13. public void Reset()
  14. {
  15. m_LOD_1 = transform.Find("LOD_1");
  16. m_LOD_2 = transform.Find("LOD_2");
  17. m_LOD_3 = transform.Find("LOD_3");
  18. }
  19. #endif
  20. public override void OnCreate()
  21. {
  22. ResetLOD(RenderManager.LOD);
  23. GlobalEvent.AddEvent(RenderEventEnum.UpdateLOD, ReceviceUpdateLOD);
  24. //Debug.Log("OnCreate " + (RenderManager.LOD));
  25. }
  26. public override void OnObjectDestroy()
  27. {
  28. GlobalEvent.RemoveEvent(RenderEventEnum.UpdateLOD, ReceviceUpdateLOD);
  29. }
  30. public void ResetLOD(int LOD)
  31. {
  32. if(m_LOD_3 != null)
  33. {
  34. m_LOD_3.gameObject.SetActive(LOD >= 3);
  35. }
  36. if (m_LOD_2 != null)
  37. {
  38. m_LOD_2.gameObject.SetActive(LOD >= 2);
  39. }
  40. }
  41. public void ReceviceUpdateLOD(params object[] objs)
  42. {
  43. ResetLOD(RenderManager.LOD);
  44. }
  45. }