41 lines
1.4 KiB
C#
41 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class IndicatorInfo : MonoBehaviourSingletonTemplate<IndicatorInfo>
|
|
{
|
|
[RuntimeInitializeOnLoadMethod]
|
|
static void OnRuntimeMethodLoad()
|
|
{
|
|
var go = new GameObject("IndicatorInfo").AddComponent<IndicatorInfo>();
|
|
DontDestroyOnLoad(go.gameObject);
|
|
}
|
|
|
|
Dictionary<string, List<GameObject>> dic_indicator = new Dictionary<string, List<GameObject>>();
|
|
|
|
public void Make_Indicator(string indicatorName, Action<GameObject> action)
|
|
{
|
|
if (dic_indicator.ContainsKey(indicatorName))
|
|
{
|
|
for (int i = 0; i < dic_indicator[indicatorName].Count; i++)
|
|
{
|
|
if (!dic_indicator[indicatorName][i].activeInHierarchy)
|
|
{
|
|
action(dic_indicator[indicatorName][i]);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
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);
|
|
if (!dic_indicator.ContainsKey(indicatorName))
|
|
dic_indicator.Add(indicatorName, new List<GameObject>());
|
|
dic_indicator[indicatorName].Add(go);
|
|
});
|
|
}
|
|
} |