public static bool SaveScenePreHook(Studio.Studio __instance, ref Camera[] __state) { IVRLog.LogDebug("Update Camera position and rotation for Scene Capture and last Camera data."); VRCameraMoveHelper.Instance.CurrentToCameraCtrl(); FieldInfo field = typeof(Studio.GameScreenShot).GetField("renderCam", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); Camera[] array = field.GetValue(Singleton <Studio.Studio> .Instance.gameScreenShot) as Camera[]; IVRLog.LogDebug("Backup Screenshot render cam."); backupRenderCam = array; Camera[] value = new Camera[] { VR.Camera.SteamCam.camera }; __state = backupRenderCam; field.SetValue(Singleton <Studio.Studio> .Instance.gameScreenShot, value); return(true); }
public static MainGameContext CreateContext(string contextName) { if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } var path = Path.Combine(configPath, contextName); var serializer = new XmlSerializer(typeof(MainGameContext)); if (File.Exists(path)) { // Attempt to load XML using (var file = File.OpenRead(path)) { try { return(serializer.Deserialize(file) as MainGameContext); } catch (Exception ex) { IVRLog.LogError($"Failed to deserialize {path} -- using default\n{ex}"); } } } // Create and save file var context = new MainGameContext(); try { using (var file = new StreamWriter(path)) { file.BaseStream.SetLength(0); serializer.Serialize(file, context); } } catch (Exception ex) { IVRLog.LogError($"Failed to write {path}\n{ex}"); } return(context); }
public static void ForceResetAsStandingMode() { try { VR.Manager.SetMode <StudioStandingMode>(); if (VR.Camera) { Camera blueprint = VR.Camera.Blueprint; Camera mainCmaera = Singleton <Studio.Studio> .Instance.cameraCtrl.mainCmaera; IVRLog.LogDebug($"Force replace blueprint camera with {mainCmaera}"); Camera camera = VR.Camera.SteamCam.camera; Camera camera2 = mainCmaera; camera.nearClipPlane = VR.Context.NearClipPlane; camera.farClipPlane = Mathf.Max(camera2.farClipPlane, 10f); camera.clearFlags = ((camera2.clearFlags == CameraClearFlags.Skybox) ? CameraClearFlags.Skybox : CameraClearFlags.Color); camera.renderingPath = camera2.renderingPath; camera.clearStencilAfterLightingPass = camera2.clearStencilAfterLightingPass; camera.depthTextureMode = camera2.depthTextureMode; camera.layerCullDistances = camera2.layerCullDistances; camera.layerCullSpherical = camera2.layerCullSpherical; camera.useOcclusionCulling = camera2.useOcclusionCulling; camera.allowHDR = camera2.allowHDR; camera.backgroundColor = camera2.backgroundColor; Skybox component = camera2.GetComponent <Skybox>(); if (component != null) { Skybox skybox = camera.gameObject.GetComponent <Skybox>(); if (skybox == null) { skybox = skybox.gameObject.AddComponent <Skybox>(); } skybox.material = component.material; } VR.Camera.CopyFX(camera2); } else { IVRLog.LogDebug("VR.Camera is null"); } } catch (Exception value) { IVRLog.LogError(value); } }
private IEnumerator ForceResetVRModeCo() { IVRLog.LogDebug("Check and reset to StandingMode if not."); yield return(null); yield return(null); yield return(null); yield return(null); yield return(null); if (!VRManager.Instance.Mode || !(VRManager.Instance.Mode is StudioStandingMode)) { IVRLog.LogDebug("Mode is not StandingMode. Force reset as Standing Mode."); ForceResetAsStandingMode(); } else { IVRLog.LogDebug("Is Standing Mode. Skip to setting force."); } yield break; }
public static void SaveScenePostHook(Studio.Studio __instance, Camera[] __state) { IVRLog.LogDebug("Restore backup render cam."); typeof(Studio.GameScreenShot).GetField("renderCam", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(Singleton <Studio.Studio> .Instance.gameScreenShot, __state); }
// 前回とSceneが変わっていれば切り替え処理をする private void DetectScene() { var nextSceneType = SceneType.NoScene; SceneInterpreter nextInterpreter = new OtherSceneInterpreter(); if (GameObject.Find("TalkScene") != null) { if (CurrentSceneType != SceneType.Talk) { nextSceneType = SceneType.Talk; //nextInterpreter = new TalkSceneInterpreter(); 特有の処理がないため不要 IVRLog.LogDebug("Start TalkScene"); } } else if (GameObject.Find("HScene") != null) { if (CurrentSceneType != SceneType.HScene) { nextSceneType = SceneType.HScene; nextInterpreter = new HSceneInterpreter(); IVRLog.LogDebug("Start HScene"); } } else if (GameObject.Find("NightMenuScene") != null) { if (CurrentSceneType != SceneType.NightMenu) { nextSceneType = SceneType.NightMenu; nextInterpreter = new NightMenuSceneInterpreter(); IVRLog.LogDebug("Start NightMenuScene"); } } else if (GameObject.Find("ActionScene") != null) { if (CurrentSceneType != SceneType.Action) { nextSceneType = SceneType.Action; nextInterpreter = new ActionSceneInterpreter(); IVRLog.LogDebug("Start ActionScene"); } } else if (GameObject.Find("CustomScene") != null) { if (CurrentSceneType != SceneType.Maker) { nextSceneType = SceneType.Maker; nextInterpreter = new MakerInterpreter(); IVRLog.LogDebug("Start MakerScene"); } } else { if (CurrentSceneType != SceneType.Other) { nextSceneType = SceneType.Other; //nextInterpreter = new OtherSceneInterpreter(); IVRLog.LogDebug("Start OtherScene"); } } if (nextSceneType != SceneType.NoScene) { SceneInterpreter.OnDisable(); CurrentSceneType = nextSceneType; SceneInterpreter = nextInterpreter; SceneInterpreter.OnStart(); } }