fix bug class run before addressable remote

This commit is contained in:
CuongNV
2026-05-21 17:18:28 +07:00
parent 5affac9cbd
commit 3dc0255eae
5 changed files with 140 additions and 24 deletions
@@ -99,7 +99,19 @@ namespace BrewMonster.Scripts
}
Debug.Log("[Cuong] AddressableManager: Bootstrap gate xong — đang InitializeAsync Addressables...");
Addressables.InitializeAsync().Completed += OnInitializeComplete;
try
{
await AddressablesInitService.EnsureInitializedAsync();
_isInitialized = true;
_initializationTcs.TrySetResult();
BMLogger.Log("AddressableManager: Initialized");
Debug.Log("[Cuong] AddressableManager: InitializeAsync xong — sẵn sàng load asset.");
}
catch (Exception e)
{
BMLogger.LogError($"AddressableManager: Failed to initialize: {e.Message}");
Debug.LogError($"[Cuong] AddressableManager: InitializeAsync thất bại — {e.Message}");
}
}
async UniTask<bool> WaitForBootstrapGateWithTimeoutAsync()
@@ -142,23 +154,6 @@ namespace BrewMonster.Scripts
#endregion
#region private functions
private void OnInitializeComplete(AsyncOperationHandle<IResourceLocator> handle)
{
if (handle.Status == AsyncOperationStatus.Succeeded)
{
_isInitialized = true;
_initializationTcs.TrySetResult();
BMLogger.Log($"AddressableManager: Initialized");
Debug.Log("[Cuong] AddressableManager: InitializeAsync xong — sẵn sàng load asset.");
}
else
{
// print out the error
BMLogger.LogError($"AddressableManager: Failed to initialize: {handle.OperationException?.Message} {handle.OperationException?.StackTrace}");
Debug.LogError($"[Cuong] AddressableManager: InitializeAsync thất bại — {handle.OperationException?.Message}");
}
}
private void RemoveFromReleaseAssetDictionary(string assetPath)
{
if (_releaseAssetTimestamps.ContainsKey(assetPath))