Files
2025-07-20 21:01:09 +08:00

47 lines
1.2 KiB
C#

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<HighLightManager>();
layerCollection = Resources.Load<OutlineLayerCollection>("OutlineLayerCollection");
}
return instance;
}
}
///// <summary>
///// 测试使用
///// </summary>
//[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);
}
}