HighLightManager.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityFx.Outline;
  5. public class HighLightManager : MonoBehaviour
  6. {
  7. static OutlineLayerCollection layerCollection;
  8. private static HighLightManager instance = null;
  9. public static HighLightManager Instance
  10. {
  11. get
  12. {
  13. if (instance == null)
  14. {
  15. GameObject go = new GameObject("HightlightMananger");
  16. DontDestroyOnLoad(go);
  17. instance = go.AddComponent<HighLightManager>();
  18. layerCollection = Resources.Load<OutlineLayerCollection>("OutlineLayerCollection");
  19. }
  20. return instance;
  21. }
  22. }
  23. ///// <summary>
  24. ///// 测试使用
  25. ///// </summary>
  26. //[RuntimeInitializeOnLoadMethod]
  27. //private static void Test()
  28. //{
  29. // Instance.ControllerHighLight(GameObject.Find("Cube"), true);
  30. //}
  31. private void OnApplicationQuit()
  32. {
  33. layerCollection?.ClearLayerContent();
  34. }
  35. public void ControllerHighLight(GameObject go, bool value)
  36. {
  37. if (value)
  38. layerCollection.GetOrAddLayer(0).Add(go);
  39. else
  40. layerCollection.GetOrAddLayer(0).Remove(go);
  41. }
  42. }