using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UTool.FxLOD; [ExecuteInEditMode] public class FxLODAgent : MonoBehaviour { public List AllFxLODInfos = new List(); private void Awake() { SetLOD(FxLODManager.Instance.LODLevel); } public void Sort() { AllFxLODInfos.Sort(SortLogic); } private static int SortLogic(FxLODInfo a, FxLODInfo b) { return b.LOD.CompareTo(a.LOD); } public void SetLOD(int lod) { bool isSetObject = false; for (int i = 0; i < AllFxLODInfos.Count; i++) { FxLODInfo fxLODInfo = AllFxLODInfos[i]; if (lod >= fxLODInfo.LOD && !isSetObject) { isSetObject = true; fxLODInfo.SetActive(true); } else { fxLODInfo.SetActive(false); } } // if (!isSetObject && AllFxLODInfos.Count > 0) // { // AllFxLODInfos[AllFxLODInfos.Count-1].SetActive(true); // } } }