| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using GFMain;
- using HighlightPlus;
- using System.Collections;
- using System.Collections.Generic;
- using UnityCommon;
- using UnityEngine;
- namespace DTYJ
- {
- /// <summary>
- /// 模型高亮控制
- /// </summary>
- public class HighlighterController : MonoSingleton<HighlighterController>
- {
- private List<GameObject> Highlights = new List<GameObject>();
- HighlightProfile highlightProfile;
- private void Awake()
- {
- MainEntry.Resource.LoadAsset("Assets/_DTYJ/_Project/Res/Effects/Highlight_equipment.asset", typeof(HighlightProfile), new GameFramework.Resource.LoadAssetCallbacks((assetName, asset, duration, userData) =>
- {
- highlightProfile = asset as HighlightProfile;
- }));
- }
- /// <summary>
- /// 打开高亮
- /// </summary>
- /// <param name="goTarget"></param>
- public void HighlightOn(GameObject goTarget)
- {
- var h = goTarget.GetOrAddComponent<HighlightEffect>();
- h.ProfileLoad(highlightProfile);
- h.highlighted = true;
- Highlights.Add(goTarget);
- }
- /// <summary>
- /// 关闭高亮
- /// </summary>
- /// <param name="goTarget"></param>
- public void HighlightOff(GameObject goTarget)
- {
- if (highlightConst.Contains(goTarget))
- return;
- _HighlightOff(goTarget);
- Highlights.Remove(goTarget);
- }
- private void _HighlightOff(GameObject goTarget)
- {
- var h = goTarget.GetComponent<HighlightEffect>();
- if (h != null)
- {
- h.highlighted = false;
- DestroyImmediate(h);
- }
- }
- /// <summary>
- /// 关闭所有高亮
- /// </summary>
- public void ClearAllHighlights()
- {
- foreach (var item in Highlights)
- {
- _HighlightOff(item);
- }
- Highlights.Clear();
- }
- List<GameObject> highlightConst = new List<GameObject>();
- public void HighlightOn_const(GameObject goTarget)
- {
- highlightConst.Add(goTarget);
- HighlightOn(goTarget);
- }
- public void HighlightOff_const(GameObject goTarget)
- {
- if (highlightConst.Contains(goTarget))
- highlightConst.Remove(goTarget);
- HighlightOff(goTarget);
- }
- }
- }
|