FxLODAgent.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UTool.FxLOD;
  6. [ExecuteInEditMode]
  7. public class FxLODAgent : MonoBehaviour
  8. {
  9. public List<FxLODInfo> AllFxLODInfos = new List<FxLODInfo>();
  10. private void Awake()
  11. {
  12. SetLOD(FxLODManager.Instance.LODLevel);
  13. }
  14. public void Sort()
  15. {
  16. AllFxLODInfos.Sort(SortLogic);
  17. }
  18. private static int SortLogic(FxLODInfo a, FxLODInfo b)
  19. {
  20. return b.LOD.CompareTo(a.LOD);
  21. }
  22. public void SetLOD(int lod)
  23. {
  24. bool isSetObject = false;
  25. for (int i = 0; i < AllFxLODInfos.Count; i++)
  26. {
  27. FxLODInfo fxLODInfo = AllFxLODInfos[i];
  28. if (lod >= fxLODInfo.LOD && !isSetObject)
  29. {
  30. isSetObject = true;
  31. fxLODInfo.SetActive(true);
  32. }
  33. else
  34. {
  35. fxLODInfo.SetActive(false);
  36. }
  37. }
  38. // if (!isSetObject && AllFxLODInfos.Count > 0)
  39. // {
  40. // AllFxLODInfos[AllFxLODInfos.Count-1].SetActive(true);
  41. // }
  42. }
  43. }