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); } }