Project_WL/Assets/Script/Mgr/AddrResourceMgr.cs

27 lines
825 B
C#
Raw Permalink Normal View History

2024-12-15 01:39:39 +00:00
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>();
}
}