private void Awake() { Managers.initInstance(); Managers.Player.init(); Managers.Camera.init(); Addressables.InitializeAsync(); }
public void LoadScene(string tag) { Debug.Log("Addressables Procedure Started for Loading Scene: " + tag + "@" + Time.time); Addressables.ClearDependencyCacheAsync(tag); Addressables.InitializeAsync().Completed += delegate { Debug.Log("Addressables.InitializeAsync.Completed:@" + Time.time); Addressables.GetDownloadSizeAsync(tag).Completed += delegate(AsyncOperationHandle <long> obj) { Debug.Log("Addressables.GetDownloadSizeAsync.Completed:@" + Time.time); float downloadSizeInMB = (float)obj.Result / 1024 / 1024; Debug.Log("GetDownloadSizeAsync: " + obj.Result + " bytes, which is " + downloadSizeInMB + " MB"); if (size) { size.text += System.Environment.NewLine + "Size of download: " + downloadSizeInMB.ToString(); } Addressables.DownloadDependenciesAsync(tag).Completed += delegate(AsyncOperationHandle opDownloadDependencies) { Debug.Log("Addressables.DownloadDependenciesAsync.Completed:" + opDownloadDependencies.Status + "@" + Time.time); Addressables.LoadSceneAsync(tag).Completed += delegate(AsyncOperationHandle <SceneInstance> opLoadScene) { Debug.Log("LoadSceneAsync.Completed: " + opLoadScene.Status + "@" + Time.time); if (opLoadScene.Status == AsyncOperationStatus.Succeeded) { } }; }; }; }; }
public void ClearDependencyCache() { var opInit = Addressables.InitializeAsync(); opInit.Completed += opInitHandle => { var resLocator = opInitHandle.Result; var allLocations = new List <IResourceLocation>(); foreach (var key in resLocator.Keys) { IList <IResourceLocation> locations; if (resLocator.Locate(key, typeof(object), out locations)) { foreach (var loc in locations) { if (loc.HasDependencies) { allLocations.AddRange(loc.Dependencies); } } } } Debug.LogFormat("ClearDependencyCacheAsync: {0}", allLocations.Count); var opClear = Addressables.ClearDependencyCacheAsync(allLocations, false); opClear.Completed += handle => { Debug.LogFormat("ClearDependencyCacheAsync Completed: {0}", handle.Result); Addressables.Release(handle); }; }; }
/// <summary> /// Addressable を初期化します /// </summary> public AddressablesControllerHandle InitializeAsync() { var source = new TaskCompletionSource <AddressablesControllerResultCode>(); var isFailure = false; m_isInitialized = false; AddressablesUtils.ResetInitializationFlag(); void OnFailure(AddressablesControllerResultCode resultCode) { AddressablesUtils.ResetInitializationFlag(); source.TrySetResult(resultCode); } void OnComplete(AsyncOperationHandle <IResourceLocator> handle) { m_exceptionHandler -= ExceptionHandler; if (isFailure) { OnFailure(AddressablesControllerResultCode.FAILURE_CANNOT_CONNECTION); return; } if (handle.Status != AsyncOperationStatus.Succeeded) { OnFailure(AddressablesControllerResultCode.FAILURE_UNKNOWN); return; } m_isInitialized = true; source.TrySetResult(AddressablesControllerResultCode.SUCCESS); } // InternalId を変換する処理を登録します Addressables.InternalIdTransformFunc = location => InternalIdTransformFunc(location); var result = Addressables.InitializeAsync(); result.Completed += handle => OnComplete(handle); // Addressables.InitializeAsync の呼び出し前にコールバックを設定すると // Addressables.InitializeAsync の中で // ResourceManager.ExceptionHandler が上書きされてしまうため // InitializeAsync の呼び出し後にコールバックを設定しています ResourceManager.ExceptionHandler = CatchException; // リモートカタログのダウンロードに失敗した場合などに呼び出されます void ExceptionHandler(Exception exception) { isFailure = true; m_exceptionHandler -= ExceptionHandler; } m_exceptionHandler += ExceptionHandler; var controllerHandle = new AddressablesControllerHandle(result, source.Task); return(controllerHandle); }
void IInitialise.Initialise() { Instance = this; FinishLoaded = false; Addressables.InitializeAsync(); var cool = new List <string>(); if (Application.isEditor) { cool.AddRange(GetCataloguePath()); } else if (GameData.Instance.DevBuild) { cool.AddRange(GetCataloguePathStreamingAssets()); } else { cool.AddRange(ServerData.ServerConfig.LobbyAddressableCatalogues); LoadCatalogue(cool, false); return; } LoadCatalogue(cool); }
IEnumerator checkUpdate() { //初始化Addressable var init = Addressables.InitializeAsync(); yield return(init); //开始连接服务器检查更新 AsyncOperationHandle <List <string> > checkHandle = Addressables.CheckForCatalogUpdates(false); //检查结束,验证结果 yield return(checkHandle); if (checkHandle.Status == AsyncOperationStatus.Succeeded) { List <string> catalogs = checkHandle.Result; if (catalogs != null && catalogs.Count > 0) { Debug.Log("download start"); var updateHandle = Addressables.UpdateCatalogs(catalogs, false); yield return(updateHandle); Debug.Log("download finish"); } } Addressables.Release(checkHandle); }
public IEnumerator CheckUpdate() { Info.text = "正在检测文件更新......."; checkingUpdate = true; var init = Addressables.InitializeAsync(); yield return(init); var check = Addressables.CheckForCatalogUpdates(false); yield return(check); switch (check.Status) { case AsyncOperationStatus.Succeeded: needUpdateCatalogs = check.Result; yield return(StartCoroutine(DownLoadUpdate())); break; default: Info.text = "更新失败"; yield break; } checkingUpdate = false; }
private static async Task <IResourceLocator> AddressablesInitializeAsync() { Debug.Log("CApplication initializing Addressables"); var op = Addressables.InitializeAsync(); var resourceLocator = await op.Task; return(resourceLocator); }
private IEnumerator InitializeAddressables() { Addressables.ResourceManager.ResourceProviders.Add(new AssetBundleProvider()); Addressables.ResourceManager.ResourceProviders.Add(new PlayFabStorageHashProvider()); Addressables.ResourceManager.ResourceProviders.Add(new PlayFabStorageAssetBundleProvider()); Addressables.ResourceManager.ResourceProviders.Add(new PlayFabStorageJsonAssetProvider()); return(Addressables.InitializeAsync()); }
void Start() { if (!Directory.Exists(_cachePath)) { Directory.CreateDirectory(_cachePath); } Caching.currentCacheForWriting = Caching.AddCache(_cachePath); Addressables.InitializeAsync().Completed += InitCompletedCallback; }
protected override void StartWork(StateStatus stateStatus) { if (stateStatus == StateStatus.Execute) { Addressables.InitializeAsync().Completed += InitCompleted; } base.StartWork(stateStatus); }
private void Awake() { instance = this; Addressables.InitializeAsync().Completed += (handle) => { Debug.Log(handle.Result.LocatorId); }; }
public void CheckForContentUpdateAndDownload() { Addressables.InitializeAsync().Completed += objects => { Addressables.ClearDependencyCacheAsync(LabelsToCheck); Addressables.CheckForCatalogUpdates().Completed += DoWhenCheckCompleted; }; }
/// <summary> /// 检查更新目录 /// </summary> /// <returns></returns> IEnumerator CheckCatalogUpdates(Action <bool> hotCallBack = null) { AsyncOperationHandle initHandle = Addressables.InitializeAsync(); yield return(initHandle); ////这里的检查更新的目录应该有其他的扩展用法,但是我们这只用来把他当AB的Manifest用 ////所以我们其实只有一个目录,不考虑多个目录的用法 AsyncOperationHandle <List <string> > catalogHandler = Addressables.CheckForCatalogUpdates(false); yield return(catalogHandler); if (catalogHandler.Status != AsyncOperationStatus.Succeeded) { ServerInfoError(); Addressables.Release(catalogHandler); yield break; } List <string> catalogs = (List <string>)catalogHandler.Result; List <IResourceLocator> locators; AsyncOperationHandle CatalogHandle; if (catalogs.Count > 0) { Debug.Log($"需要更新资源的目录"); //下载新的目录 //这个目录里面包含整个项目所有被Addressable管理的资源的地址 //同一份资源有俩个地址,一个是设置的一个是它的hash值 CatalogHandle = Addressables.UpdateCatalogs(catalogs, false); yield return(CatalogHandle); if (CatalogHandle.Status != AsyncOperationStatus.Succeeded) { ServerInfoError(); yield break; } locators = (List <IResourceLocator>)CatalogHandle.Result; } else { //当成AB的manifest去获取一次资源目录 Debug.Log($"不需要更新资源的目录"); IEnumerable <IResourceLocator> ielocators = Addressables.ResourceLocators; locators = new List <IResourceLocator>(); foreach (var locator in ielocators) { locators.Add(locator); } } //检查资源更新 m_Startmono.StartCoroutine(ComputeDownload(locators, hotCallBack)); Addressables.Release(catalogHandler); }
public override async Task Setup(IContext context) { base.Setup(context); _cachedSpriteDictionary = new Dictionary <string, Sprite>(); _cachedPrefabDictionary = new Dictionary <string, GameObject>(); _cachedAddressableLocations = new Dictionary <string, IResourceLocation>(); Addressables.InitializeAsync(); await GetAllLocations(); }
/// <summary> /// 初始化操作 /// </summary> /// <param name="complete"></param> public static void InitializeAsync([NotNull] Action callBack) { Addressables.InitializeAsync().Completed += (complete) => { if (complete.IsDone) { callBack(); } }; }
private async void Start() { BeforePreInit?.Invoke(); BeforePreInit = null; await Addressables.InitializeAsync().Task; await PreInitGame(); Addressables.InstantiateAsync("panel.debug").Completed += h => h.Result.GetComponent <PanelDebug>().Init(); InitGame(); }
public ETTask Init() { ETTaskCompletionSource tcs = new ETTaskCompletionSource(); AsyncOperationHandle initasync = Addressables.InitializeAsync(); initasync.Completed += op => { tcs.SetResult(); }; return(tcs.Task); }
public static AsyncOperationHandle InitializeAsync() { //DebugUtility.LogTrace(LoggerTags.AssetManager, "AssetManager.InitializeAsync"); var h = Addressables.InitializeAsync(); //h.Completed += opHandle => //{ //}; return(h); }
IEnumerator InitAsset(int weight) { var handle = Addressables.InitializeAsync(); while (!handle.IsDone) { yield return(null); } AssetManager.Initialize(); yield return(weight); }
public IEnumerator BeforeInit() { CSpriteAtlasManager.GetInstance().Initialize(); var op = Addressables.InitializeAsync(); op.Completed += (s) => { AddressableMgr.GetInstance().Initialize(); }; yield return(op); yield return(CSpriteAtlasManager.instance.LoadAllSpriteAtlas(AddressableMgr.instance.spriteAtlasPrimaryKeys)); SceneManager.LoadScene("UI"); }
private IEnumerator DownloadUpdateAsync() { var initHandle = Addressables.InitializeAsync(); yield return(initHandle); Addressables.Release(initHandle); var checkHandle = Addressables.CheckForCatalogUpdates(false); yield return(checkHandle); var catalogs = checkHandle.Result; Addressables.Release(checkHandle); if (catalogs == null || catalogs.Count <= 0) { yield break; } SaveOriginalCatalogs(); yield return(StartCoroutine(UpdateCatalogsAsync(catalogs))); yield return(StartCoroutine(CalculateUpdateSizeAsync())); if (downloadSize <= 0) { yield break; } yield return(StartCoroutine(RequestDownloadHandle?.Invoke(downloadSize))); if (Result == RequestDownloadResult.Agree) { DeleteOriginalCatalogs(); } else { CancelDownload(); } yield return(StartCoroutine(UpdateResourceLocatorsAsync())); if (Result == RequestDownloadResult.Disagree) { yield break; } yield return(StartCoroutine(DownloadAsync())); OnDownloadCompleted?.Invoke(downloadSize); yield return(StartCoroutine(AfterDownloadHandle?.Invoke())); }
IEnumerator Start() { yield return(Addressables.InitializeAsync()); yield return(new WaitForSeconds(1)); var asyncOperation = sceneReference.LoadSceneAsync(LoadSceneMode.Additive); yield return(asyncOperation); var scene = asyncOperation.Result; yield return(new WaitForSeconds(3)); yield return(Addressables.UnloadSceneAsync(scene)); }
void CheckEveryXSeconds() { if (autoUpdate == false) { Addressables.InitializeAsync().Completed += InitDone; autoUpdate = true; } if (foundpacket) { CancelInvoke("CheckEveryXSeconds"); return; } //Addressables.CheckForCatalogUpdates(false).Completed += OnCheckingCatalogs; }
public async void CheckForCatalogUpdates() { await Addressables.InitializeAsync().Task; AsyncOperationHandle <List <string> > handle = Addressables.CheckForCatalogUpdates(false); await handle.Task; if (handle.Status == AsyncOperationStatus.Succeeded) { List <string> catalogList = handle.Result; if (catalogList != null && catalogList.Count > 0) { UpdateCatalogs(catalogList); } } Addressables.Release(handle); }
IEnumerator checkUpdate() { checkingUpdate = true; //初始化Addressable var init = Addressables.InitializeAsync(); yield return(init); var start = DateTime.Now; //开始连接服务器检查更新 AsyncOperationHandle <List <string> > handle = Addressables.CheckForCatalogUpdates(false); //检查结束,验证结果 checkingUpdate = false; Debug.Log(string.Format("CheckIfNeededUpdate use {0}ms", (DateTime.Now - start).Milliseconds)); yield return(handle); if (handle.Status == AsyncOperationStatus.Succeeded) { List <string> catalogs = handle.Result; if (catalogs != null && catalogs.Count > 0) { needUpdate = true; needUpdateCatalogs = catalogs; } } if (needUpdate) { //检查到有资源需要更新 statusText.text = "有资源需要更新"; //Reg.PlatformAPI.SetAddressableMsg("有资源需要更新"); downLoad.SetActive(true); startUp.SetActive(false); StartDownLoad(); } else { //Reg.PlatformAPI.SetAddressableMsg($"Loading..."); //没有资源需要更新,或者连接服务器失败 Skip(); } Addressables.Release(handle); }
async UniTaskVoid Startup() { try { await Addressables.InitializeAsync(); AssetTypeC toLoad = await Addressables.LoadAssetAsync <AssetTypeC>(AddressToLoad); MatToAssign.sharedMaterial = toLoad.SomeRef.SomeRef.MatRef; } catch { MatToAssign.sharedMaterial = Fallback; throw; } }
public async void UpdateCatalog() { var start = DateTime.Now; var initHandle = Addressables.InitializeAsync(); await initHandle.Task; var checkHandle = Addressables.CheckForCatalogUpdates(false); await checkHandle.Task; Debug.Log(string.Format("CheckIfNeededUpdate use {0}ms", (DateTime.Now - start).Milliseconds)); Debug.Log($"catalog count: {checkHandle.Result.Count} === check status: {checkHandle.Status}"); if (checkHandle.Status == AsyncOperationStatus.Succeeded) { List <string> catalogs = checkHandle.Result; if (catalogs != null && catalogs.Count > 0) { needUpdateRes = true; status_Text.text = "正在更新资源..."; update_Slider.normalizedValue = 0f; update_Slider.gameObject.SetActive(true); start = DateTime.Now; AsyncOperationHandle <List <IResourceLocator> > updateHandle = Addressables.UpdateCatalogs(catalogs, false); await updateHandle.Task; var locators = updateHandle.Result; Debug.Log($"locator count: {locators.Count}"); foreach (var v in locators) { var sizeHandle = Addressables.GetDownloadSizeAsync(v.Keys); await sizeHandle.Task; long size = sizeHandle.Result; Debug.Log($"download size:{size}"); if (size > 0) { //UINoticeTip.Instance.ShowOneButtonTip("更新提示", $"本次更新大小:{size}", "确定", null); //yield return UINoticeTip.Instance.WaitForResponse(); downloadHandle = Addressables.DownloadDependenciesAsync(v.Keys, Addressables.MergeMode.Union); await downloadHandle.Task; Addressables.Release(downloadHandle); } } Debug.Log(string.Format("UpdateFinish use {0}ms", (DateTime.Now - start).Milliseconds)); Addressables.Release(updateHandle); } Addressables.Release(checkHandle); } }
public static async void LoadGameData() { await Addressables.InitializeAsync().Task; List <Task> loadOps = new List <Task>(); // TODO - I'm quite happy with this ngl loadOps.Add(LoadEntityData()); loadOps.Add(LoadItemData()); loadOps.Add(LoadTileData()); loadOps.Add(LoadItemPrefab()); await Task.WhenAll(loadOps); dataLoaded = true; Debug.Log("LOADED"); }
// Start is called before the first frame update IEnumerator Start() { _uiRoot = GameObject.Find("UIRoot"); DontDestroyOnLoad(_uiRoot); _rootLayer = GameObject.Find("LaunchLayer").GetComponent <Canvas>(); //初始化Addressable var init = Addressables.InitializeAsync(); yield return(init); yield return(InitLaunchView()); // DontDestroyOnLoad(_objPool); DontDestroyOnLoad(gameObject); DontDestroyOnLoad(GameObject.Find("scene_root")); }