public void Add(string name, Action <GameObject> onComplete = null) { var o = new LoaderOperationInfo() { Name = name, OnComplete = onComplete }; _operationInfos.Add(o); }
private void LoadObject(LoaderOperationInfo operationInfo) { Addressables.InstantiateAsync(operationInfo.Name).Completed += objectLoadedHandler; void objectLoadedHandler(AsyncOperationHandle <GameObject> handle) { if (handle.Status == AsyncOperationStatus.Succeeded) { operationInfo.OnComplete?.Invoke(handle.Result); _finishedOperations++; } else { Debug.LogError($"Asset loading failure: {handle.DebugName}"); } } }