private IEnumerator Reload(VivePackage vp) { yield return(StartCoroutine(WaitForActivity())); var wasSceneLoaded = false; if (vp == _loadedScenePackage) { wasSceneLoaded = true; StartSceneUnload(vp); yield return(StartCoroutine(WaitForActivity())); } StartCleanup(vp); yield return(StartCoroutine(WaitForActivity())); if (!wasSceneLoaded) { yield break; } yield return(StartCoroutine(WaitForActivity())); StartSceneLoad(vp); }
private IEnumerator FullUnload(VivePackage vp) { _vivePackages.Remove(vp.PackageName); if (_loadedScenePackage == vp) { StartSceneUnload(vp); yield return(StartCoroutine(WaitForActivity())); } StartCleanup(vp); }
private void DrawPackageGui(VivePackage vp) { using (new GUILayout.VerticalScope("box")) { GUILayout.Label(vp.PackageName); var isCurrentSceneLoaded = _loadedScenePackage == vp; if (!vp.IsUnPacked && GUILayout.Button(UnpackBtnContent)) { StartUnpack(vp); } else if (vp.IsUnPacked && GUILayout.Button(CleanupBtnContent)) { StartCleanup(vp); } if (vp.IsUnPacked) { if (vp.HasScene) { using (new GUILayout.HorizontalScope()) { if (!isCurrentSceneLoaded && GUILayout.Button(LoadSceneBtnContent)) { StartSceneLoad(vp); } else if (isCurrentSceneLoaded && GUILayout.Button(UnloadSceneBtnContent)) { StartSceneUnload(vp); } GUILayout.Space(10.0f); GUILayout.Label(vp.SceneName); } } if (vp.HasSkybox) { using (new GUILayout.HorizontalScope()) { if (GUILayout.Button(LoadSkyboxBtnContent)) { StartSkyboxLoad(vp); } } } // TODO: Load/Display/Unload objects } } }
private void StartSkyboxLoad(VivePackage vp) { _activity = Loader.LoadSkybox(vp.SkyboxFile) .Subscribe(res => { ApplySkybox(res); _activity = null; }, ex => { Debug.LogException(ex); _activity = null; }); }
private void OnSceneUnloadComplete() { _loadedScenePackage = null; _activity = null; Interactivity.ResetTeleport(this); SceneManager.SetActiveScene(_baseActiveScene); ToggleGosForPreview(true, _gosToHideInPreview); ToggleGosForPreview(false, _gosToShowInPreview); ApplySkybox(_skyboxCubemap); //RenderSettings.fog = true; RenderSettings.ambientMode = AmbientMode.Skybox; }
private void OnPackageRenamed(object source, RenamedEventArgs e) { var on = e.OldName; VivePackage vp; if (_vivePackages.TryGetValue(on, out vp)) { StartCoroutine(FullUnload(vp)); } var nvp = new VivePackage(e.FullPath); _vivePackages.Add(nvp.PackageName, nvp); }
private void StartCleanup(VivePackage vp, bool cleanResources = false) { Directory.Delete(vp.PackageDirectoryPath, true); vp.CheckFileReferences(); if (cleanResources) { _activity = Observable.FromMicroCoroutine(Clean) .Subscribe( _ => _activity = null, ex => { Debug.LogException(ex); _activity = null; }); } }
private void FindExistingVivePackages() { var dlcDir = DlcPath.DlcDirectory; if (!Directory.Exists(dlcDir)) { Directory.CreateDirectory(dlcDir); } var vivePackagePaths = Directory.GetFiles(dlcDir, DlcPath.PackageWildcard).Distinct(); foreach (var packagePath in vivePackagePaths) { var vp = new VivePackage(packagePath); _vivePackages.Add(vp.PackageName, vp); } }
private void StartSceneLoad(VivePackage vp) { Action load = () => { _activity = Loader.LoadScene(vp.SceneFile) .Subscribe(res => { vp.Scene = res; _loadedScenePackage = vp; ToggleGosForPreview(false, _gosToHideInPreview); ToggleGosForPreview(true, _gosToShowInPreview); Interactivity.Setup( new Interactivity.Parameters( vp.Scene, this, GetMixer)); SceneManager.SetActiveScene(vp.Scene); ApplySkybox(_skyboxCubemap); //RenderSettings.fog = false; RenderSettings.ambientMode = AmbientMode.Skybox; _activity = null; }, OnSceneError); }; if (_loadedScenePackage != null) { _activity = Loader.UnloadScene(_loadedScenePackage.Scene) .Subscribe(err => { OnSceneUnloadComplete(); load(); }, OnSceneError); } else { load(); } }
private void StartUnpack(VivePackage vp) { _activity = Extraction.ExtractPackage( new Extraction.Parameters( vp.AppId, vp.PackageFilePath, vp.PackageDirectoryPath)) .Subscribe(_ => { vp.CheckFileReferences(); _activity = null; }, ex => { Debug.LogException(ex); _activity = null; }); }
private void OnPackageChanged(object source, FileSystemEventArgs e) { VivePackage vp; switch (e.ChangeType) { case WatcherChangeTypes.Changed: if (!_vivePackages.TryGetValue(e.Name, out vp)) { return; } StartCoroutine(Reload(vp)); return; case WatcherChangeTypes.Deleted: if (!_vivePackages.TryGetValue(e.Name, out vp)) { return; } StartCoroutine(FullUnload(vp)); return; case WatcherChangeTypes.Created: if (_vivePackages.TryGetValue(e.Name, out vp)) { StartCoroutine(Reload(vp)); return; } vp = new VivePackage(e.FullPath); _vivePackages.Add(vp.PackageName, vp); return; } }
private void StartSceneUnload(VivePackage vp) { _activity = Loader.UnloadScene(vp.Scene) .Subscribe(_ => OnSceneUnloadComplete(), OnSceneError); }