using System; using System.Collections; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; public class AddrResourceMgr : MonoBehaviourSingletonTemplate { // Start is called before the first frame update void Start() { DontDestroy(); } public void LoadObject(string path, Action> onCompleted) { // Addressables에서 비동기 로드 AsyncOperationHandle handle = Addressables.LoadAssetAsync($"Assets/Res_Addr/{path}"); // 로딩 완료 시 호출될 콜백 handle.Completed += onCompleted; } //public void Set_AddressableReleaseSelf(GameObject go) //{ // if (DSUtil.CheckNull(go.GetComponent())) // go.AddComponent(); //} public IEnumerator LoadObjectSequential(string path, Action onLoaded) { // 로드 요청 AsyncOperationHandle handle = Addressables.LoadAssetAsync($"Assets/Res_Addr/{path}"); // 완료될 때까지 대기 yield return handle; // 결과 전달 if (handle.Status == AsyncOperationStatus.Succeeded) { onLoaded?.Invoke(handle.Result); } else { Debug.LogError($"Failed to load: {path}"); } // 필요하다면 해제는 여기서 // Addressables.Release(handle); } }