1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UTool.FxLOD;
- [ExecuteInEditMode]
- public class FxLODAgent : MonoBehaviour
- {
-
- public List<FxLODInfo> AllFxLODInfos = new List<FxLODInfo>();
- 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);
- // }
- }
- }
|