27 lines
825 B
C#
27 lines
825 B
C#
|
|
using System;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.AddressableAssets;
|
||
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
||
|
|
|
||
|
|
public class AddrResourceMgr : MonoBehaviourSingletonTemplate<AddrResourceMgr>
|
||
|
|
{
|
||
|
|
// Start is called before the first frame update
|
||
|
|
void Start()
|
||
|
|
{
|
||
|
|
DontDestroy();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void LoadObject<T>(string path, Action<AsyncOperationHandle<T>> onCompleted)
|
||
|
|
{
|
||
|
|
// Addressables에서 비동기 로드
|
||
|
|
AsyncOperationHandle<T> handle = Addressables.LoadAssetAsync<T>(path);
|
||
|
|
|
||
|
|
// 로딩 완료 시 호출될 콜백
|
||
|
|
handle.Completed += onCompleted;
|
||
|
|
}
|
||
|
|
public void Set_AddressableReleaseSelf(GameObject go)
|
||
|
|
{
|
||
|
|
if (DSUtil.CheckNull(go.GetComponent<AddressableReleaseSelf>()))
|
||
|
|
go.AddComponent<AddressableReleaseSelf>();
|
||
|
|
}
|
||
|
|
}
|