private IEnumerator LoadAsync(string sceneName) { ResourceLoader.LoadScene(sceneName); AsyncOperation operation = SceneManager.LoadSceneAsync(sceneName); operation.allowSceneActivation = false; int toPercent = 0; int curPercent = 0; while (operation.progress < 0.9f) { toPercent = (int)operation.progress * 100 - curPercent; yield return(IncreaseInstruction(curPercent, toPercent)); } toPercent = 100; yield return(IncreaseInstruction(curPercent, toPercent)); operation.allowSceneActivation = true; yield return(operation); if (null != SwtichingScene) { SwtichingScene.Invoke(); } if (null != LoadComplete) { LoadComplete.Invoke(); } }
public async void Setup(SyncObject obj) { // TODO: dynamic model change handling if (!obj.HasField("model") || !(obj.GetField("model") is BlobHandle)) { // TODO: obj.WriteErrorLog("Model", $"This object has no model field or not a blob handle. Ignoring."); return; } BlobHandle handle = (BlobHandle)obj.GetField("model"); Blob blob = await obj.Node.ReadBlob(handle); obj.WriteDebugLog("Model", $"Blob {handle} loaded"); // Because UniGLTF.ImporterContext is the parent class of VRMImporterContext, // ( https://github.com/vrm-c/UniVRM/blob/3b68eb7f99bfe78ea9c83ea75511282ef1782f1a/Assets/VRM/UniVRM/Scripts/Format/VRMImporterContext.cs#L11 ) // loading procedure is probably almost same (See PlyayerAvatar.cs for VRM loading). // https://github.com/vrm-c/UniVRM/blob/3b68eb7f99bfe78ea9c83ea75511282ef1782f1a/Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs#L46 ctx = new UniGLTF.ImporterContext(); // ParseGlb parses GLB file. // https://github.com/vrm-c/UniVRM/blob/3b68eb7f99bfe78ea9c83ea75511282ef1782f1a/Assets/VRM/UniGLTF/Scripts/IO/ImporterContext.cs#L239 // Currently, only GLB (glTF binary format) is supported because it is self-contained ctx.ParseGlb(blob.Data); ctx.Root = gameObject; await ctx.LoadAsyncTask(); // UniGLTF also has ShowMeshes https://github.com/ousttrue/UniGLTF/wiki/Rutime-API#import ctx.ShowMeshes(); obj.WriteDebugLog("Model", "Model load completed"); LoadComplete?.Invoke(this); }
private void StartLoad() { _filmRepository.SetConnection(_connectionString); var films = GetFilms(); var viewFilms = FilmsToViewModel(films); _filmBindingList = new BindingList <FilmViewModel>(viewFilms); LoadComplete?.Invoke(this, EventArgs.Empty); }
public async Task LoadLibraryAsync(string fileName, bool precache = false) { try { LoadProgress?.Invoke(this, new TransitionLibraryProgressEventArgs(0, 1, "loading transitions settings")); var transitions = await ConfigParser.ParseAsync(fileName); foreach (var transition in transitions) { TransitionData?transitionData = null; switch (transition[0]) { case "SoundAndGif": float.TryParse(transition[3], out var duration); transitionData = new SoundAndGifTransitionData(transition[1], transition[2], duration); break; } if (transitionData != null) { if (TransitionCache.ContainsKey(transitionData.Hash)) { TransitionCache[transitionData.Hash].Count++; } else { TransitionCache.Add(transitionData.Hash, transitionData); } } } ListReady?.Invoke(this, null); if (precache) { int current = 0; int total = TransitionCache.Count(); while (current < TransitionCache.Count()) { var toCache = TransitionCache.Skip(current).Take(2).ToList(); Task[] tasks = toCache.Select(tc => tc.Value.PreloadAsync()).ToArray(); await Task.WhenAll(tasks); current += toCache.Count(); LoadProgress?.Invoke(this, new TransitionLibraryProgressEventArgs(current, total, "Preloading")); } } } catch (Exception ex) { CustomMainForm.Log($"{ex.StackTrace}"); CustomMainForm.Log($"{ex.Message}"); } finally { LoadComplete?.Invoke(this, null); } }
private void InitialSyncCompleted(MessageBase msg) { lock (readyLock) { _asyncReady = true; _logger.LogDebug("initial sync complete"); if (Ready) { LoadComplete?.Invoke(this, new EventArgs()); } } }
/// <summary> /// ロード /// </summary> private IEnumerator LoadAssetAsync <TObject>(string key, string path, LoadComplete <TObject> loadEndEvent) { var handle = Addressables.LoadAssetAsync <TObject>(path); yield return(handle); bool isSucceeded = handle.Status == AsyncOperationStatus.Succeeded; if (isSucceeded) { _LoadHandleList.Add(key, new AddressableInfo(path, handle)); } loadEndEvent?.Invoke(isSucceeded, handle.Result); }
/// <summary> /// Se ejecuta al cargar el mapa /// </summary> public void OnLoadComplete(string load) { if (!string.IsNullOrEmpty(load)) { IsLoad = load == "bingmapv8_loadcomplete"; if (IsLoad) { LoadComplete?.Invoke(this, EventArgs.Empty); System.Diagnostics.Debug.WriteLine("Se ha cargado el mapa", "BingMapV8"); } } else { } }
public IEnumerator LoadABWWW() { using (WWW www = new WWW(_downloadPath)) { // 创建下载Ab包使用的WWW对象 yield return www; if (www.progress >= 1) { // 下载完毕 AssetBundle downloadAb = www.assetBundle; // 从下载的资源中提取出AssetBundle if (downloadAb != null) { _assetLoader = new AssetLoader(downloadAb); // AssetLoader实例化,用于加载资源 _loadCompleteHandler?.Invoke(_abName); // AssetBundle下载完毕,调用委托方法 } else { Debug.LogError($"{GetType()}/LoadAssetBundleWWW方法使用参数路径" + $"_downloadPath = {_downloadPath}下载AssetBundle失败,请检查输入"); } } } // using_End }
void LoadAssets(string path, LoadComplete cb, object obj = null) { if (mAssetsABDic.ContainsKey(path)) { AssetsBundleData abd = mAssetsABDic[path]; abd.depIndex += 1; UnityEngine.Object o = GetObj(abd.ab, path); if (cb != null) { cb.Invoke(o, obj); } } else { SynLoadAssets(path, false, obj, cb); } }
static void Load(SaveFile saveFile) { Migrations.Migrate(saveFile); PreLoad?.Invoke(); GameTime.save = saveFile.gameTime; CurrencySystem.instance.save = saveFile.currency; ConveyorSystem.instance.save = saveFile.conveyor; MachineSystem.instance.save = saveFile.machine; TileSelectionManager.instance.save = saveFile.tileSelection; OverviewCameraController.instance.save = saveFile.overviewCameraController; Analytics.instance.save = saveFile.analytics; BackgroundMusic.instance.SetSave(in saveFile.backgroundMusic); InterfaceSelectionManager.instance.SetSave(in saveFile.interfaceSelection); MachineGroupAchievements.instance.SetSave(in saveFile.machineGroupAchievements); MachineUnlockSystem.instance.SetSave(in saveFile.machineUnlocks); ProgressionStore.instance.SetSave(in saveFile.progressionSystem); SpacePlatform.SetSave(in saveFile.spacePlatforms); PostLoad?.Invoke(); LoadComplete?.Invoke(); }
/// <summary> /// 真正加载的地方 /// </summary> /// <param name="path"></param> /// <param name="dp"></param> /// <param name="cb"></param> /// <param name="obj"></param> /// <returns></returns> void SynLoadAssets(string path, bool dp, object obj, LoadComplete cb) { if (mNameMD5Dic.ContainsKey(path)) { VersionAssetData vad = mNameMD5Dic[path]; string url = GetAssetsFilePath(vad.path, vad.md5); AssetBundle ab = null; if (!dp) { // 作为主资源加载的 AssetsBundleData abd = null; if (mAssetsABDic.ContainsKey(path))//已经被加载过 计数器自增 { abd = mAssetsABDic[path]; abd.depIndex += 1; ab = abd.ab; } else { // 新加载的 ab = AssetBundle.LoadFromFile(url); abd = new AssetsBundleData(); abd.name = path; abd.depIndex = 1; abd.ab = ab; mAssetsABDic.Add(path, abd); } string[] dpAbs = mMainManifest.GetAllDependencies(path); //取这个资源的所有依赖资源 #region if (dpAbs != null && dpAbs.Length == 0) //没有依赖 获取资源 { UnityEngine.Object o = GetObj(ab, path); if (cb != null) { cb.Invoke(o, obj); } } #endregion #region else { //存在依赖资源 #region for (int i = 0; i < dpAbs.Length; i++) { if (mAssetsABDic.ContainsKey(dpAbs[i])) { // 依赖计数器中已经存在了 计数器+1 abd = mAssetsABDic[dpAbs[i]]; abd.depIndex += 1; } else { SynLoadAssets(dpAbs[i], true, obj, cb); } } //依赖都加载完毕了 再看主资源 UnityEngine.Object o = GetObj(ab, path); if (cb != null) { cb.Invoke(o, obj); } #endregion } } #endregion else { // 作为被依赖资源下载 AssetsBundleData abd = null; if (mAssetsABDic.ContainsKey(path)) { abd = mAssetsABDic[path]; abd.depIndex += 1; } else//被依赖的 缓存 { ab = AssetBundle.LoadFromFile(url); abd = new AssetsBundleData(); abd.name = path; abd.depIndex = 1; abd.ab = ab; mAssetsABDic.Add(path, abd); } } } else { Debug.LogError("cannot find:" + path); } }
private void notifyLoadComplete(T loaded) { IsBusy = false; LoadComplete?.Invoke(loaded); }
protected virtual void OnLoadComplete() { LoadComplete?.Invoke(this, EventArgs.Empty); }
/// <summary> /// /// </summary> private void OnLoadComplete(TimeSpan duration, bool cancelled) { LoadComplete?.Invoke(this, this.FileName, duration, cancelled); }
private void ReportLoadComplete() { Log.Output(LogCategory, $"Finished loading asset bundles."); LoadComplete?.Invoke(); }
/// <summary> /// 完成名称为abName的AssetBundle的回调方法 /// </summary> /// <param name="abName">AssetBundle名称</param> private void CompleteLoadSingle(string abName) { if (abName.Equals(_currAssetBundleName)) { _loadAllComplete?.Invoke(abName); } }
private void OnLoadComplete(object val) { LoadComplete?.Invoke(this, (EventArgs)val); }
public static void LoadInitiated() => LoadComplete?.Invoke(null, EventArgs.Empty);
private void OnLoadComplete() { LoadComplete?.Invoke(this, EventArgs.Empty); }