Project_WL/Assets/Script/Ingame/Obj/IndicatorInfo.cs

30 lines
1.0 KiB
C#
Raw Normal View History

2025-02-20 01:30:24 +00:00
using System;
2025-02-25 00:53:33 +00:00
using System.Collections.Generic;
2025-02-20 01:30:24 +00:00
using UnityEngine;
public class IndicatorInfo : MonoBehaviourSingletonTemplate<IndicatorInfo>
{
[RuntimeInitializeOnLoadMethod]
static void OnRuntimeMethodLoad()
{
var go = new GameObject("IndicatorInfo").AddComponent<IndicatorInfo>();
DontDestroyOnLoad(go.gameObject);
}
2025-02-25 00:53:33 +00:00
Dictionary<string, GameObject> dic_indicator = new Dictionary<string, GameObject>();
2025-02-20 01:30:24 +00:00
public void Make_Indicator(string indicatorName, Action<GameObject> action)
{
2025-02-25 00:53:33 +00:00
if (dic_indicator.ContainsKey(indicatorName))
action(dic_indicator[indicatorName]);
else
AddrResourceMgr.Ins.LoadObject<GameObject>($"Assets/Res_Addr/Obj/{indicatorName}.prefab", handle =>
{
var go = DSUtil.Get_Clone(handle.Result);
go.transform.parent = transform;
AddrResourceMgr.Ins.Set_AddressableReleaseSelf(go);
action(go);
dic_indicator.Add(indicatorName, go);
});
2025-02-20 01:30:24 +00:00
}
}