using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityFx.Outline; public class HighLightManager : MonoBehaviour { static OutlineLayerCollection layerCollection; private static HighLightManager instance = null; public static HighLightManager Instance { get { if (instance == null) { GameObject go = new GameObject("HightlightMananger"); DontDestroyOnLoad(go); instance = go.AddComponent(); layerCollection = Resources.Load("OutlineLayerCollection"); } return instance; } } ///// ///// 测试使用 ///// //[RuntimeInitializeOnLoadMethod] //private static void Test() //{ // Instance.ControllerHighLight(GameObject.Find("Cube"), true); //} private void OnApplicationQuit() { layerCollection?.ClearLayerContent(); } public void ControllerHighLight(GameObject go, bool value) { if (value) layerCollection.GetOrAddLayer(0).Add(go); else layerCollection.GetOrAddLayer(0).Remove(go); } }