private void CheckXRStatus() { #if USING_XR_MANAGEMENT VRPlugin = VRMode.XRPlugin; XRPluginLoader = XRGeneralSettings.Instance.Manager.activeLoader?.name ?? ""; //var loaders = string.Join(",", XRGeneralSettings.Instance.Manager.activeLoaders.Select(e => e.name)); Debug.Log($"{ XRGeneralSettings.Instance.Manager.automaticLoading}"); Debug.Log($"XRGeneralSettings.Instance.Manager.isInitializationComplete { XRGeneralSettings.Instance.Manager.isInitializationComplete}"); //Debug.Log($"XRPlugin Detected | XRSettings.enabled {XRSettings.enabled} | Loader : {XRPluginLoader} | Loaders Enabled: {loaders}"); XRPluginActive = XRSettings.enabled && XRGeneralSettings.Instance.Manager.isInitializationComplete; #elif !UNITY_2020_1_OR_NEWER var legacyDevices = ""; foreach (var t in XRSettings.supportedDevices) { legacyDevices += t + ","; } Debug.Log($"Legacy VR Detected | XRSettings.enabled {XRSettings.enabled} | SDKs: {legacyDevices}"); VRPlugin = VRMode.Legacy; LegacyActive = XRSettings.enabled && !string.IsNullOrWhiteSpace(XRSettings.loadedDeviceName); #endif }
void OnSwitchVRMode(Message msg) { Reset(); VRMode to = (VRMode)msg.GetMessage(Global.MSG_SWITCHVRMODE_MODE_KEY); SetToMode(to); }
void toggle() { if (vrMode == VRMode.VROn) { Debug.Log("Starting Non-VR"); VRSettings.LoadDeviceByName("None"); vrMode = VRMode.VROff; } else { Debug.Log("Starting VR"); VRSettings.LoadDeviceByName("daydream"); vrMode = VRMode.VROn; } }
void OnSwitchVRMode(Message msg) { VRMode to = (VRMode)msg.GetMessage(Global.MSG_SWITCHVRMODE_MODE_KEY); if (head == null) { head = FindObjectOfType(typeof(CardboardHead)) as CardboardHead; } if (to == VRMode.VR_2D && LogicManager.ActiveWindow != WindowArg.Type.PLAY_WINDOW) { head.isLockVertical = true; } else { head.isLockVertical = false; } }
void SetToMode(VRMode to) { Image img = GetComponent <Image>(); if ((to & mode) > 0) { if (img != null) { img.raycastTarget = true; } } else { if (img != null) { img.raycastTarget = false; } } }
void OnSwitchVRMode(Message msg) { VRMode to = (VRMode)msg.GetMessage(Global.MSG_SWITCHVRMODE_MODE_KEY); Debug.Log("Reticle to " + to); if (to == VRMode.VR_2D) { MeshRenderer[] renders = GetComponentsInChildren <MeshRenderer>(); foreach (MeshRenderer r in renders) { r.enabled = false; } } else { MeshRenderer[] renders = GetComponentsInChildren <MeshRenderer>(); foreach (MeshRenderer r in renders) { r.enabled = true; } } }
/// <summary> /// Update the scene /// </summary> /// <param name="gameTime">The game time.</param> protected override void Update(TimeSpan gameTime) { base.Update(gameTime); if (this.cachedMonoscopicValue != this.cameraRig.Monoscopic) { this.cachedMonoscopicValue = this.cameraRig.Monoscopic; this.needRefreshBarrelModel = true; } if (this.cachedVRMode != this.cameraRig.VRMode) { this.cachedVRMode = this.cameraRig.VRMode; this.needRefreshBarrelModel = true; } if (this.needRefreshBarrelModel) { this.RefreshBarrelDistortionScene(); this.needRefreshBarrelModel = false; } this.UpdateEyePoses(); }
static public void SetVRMode(VRMode to) { Debug.Log("Set VRMode to " + to + " Cardboard " + CardBoard); m_vr_mode = to; if (to == VRMode.VR_2D) { if (CardBoard != null) { CardBoard.VRModeEnabled = false; } } else // to 3d mode { if (CardBoard != null) { CardBoard.VRModeEnabled = true; } } Message msg = new Message(Instance); msg.AddMessage(Global.MSG_SWITCHVRMODE_MODE_KEY, to); VREvents.FireSwitchVRMode(msg); }
private void RefreshVRMode() { AttachedCamera.IsActive = VRMode.HasFlag(VRMode.AttachedMode); LeftEyeCamera.IsActive = RightEyeCamera.IsActive = VRMode.HasFlag(VRMode.HmdMode); }
public MainForm(VRMode vrMode = VRMode.Any) { InitializeComponent(); this._jsonIni = new JSONINIFile(); this._playerHeight = DEFAULT_HEIGHT; this._paused = false; this._scalePaused = false; this.cbTargetTimeUnit.SelectedIndex = 0; string pHeight = this._jsonIni.Read("Height", null, "invalid"); float pHeightF; if (float.TryParse(pHeight, out pHeightF) && pHeightF > 100 && pHeightF < 250) { this._playerHeight = pHeightF; } MainForm.WriteTextboxThreadSafe(txtPlayerHeight, this._playerHeight.ToString(CultureInfo.InvariantCulture)); this._jsonIni.Write("Height", this._playerHeight.ToString(CultureInfo.InvariantCulture)); this._subtitleOffset = (float)(this._jsonIni.ReadFloat("SubtitleOffset", null, 30.0)); if (this._subtitleOffset < -20 || this._subtitleOffset > 100) { this._subtitleOffset = 30.0f; } //this.txtSubtitleOffset.Text = this._subtitleOffset.ToString(CultureInfo.InvariantCulture); this.txtTargetScale.Text = this._jsonIni.ReadFloat("ProcessSpeed", null, 0.5).ToString(CultureInfo.InvariantCulture); this.txtTargetTimeValue.Text = this._jsonIni.ReadFloat("ProcessTime", null, 30).ToString(CultureInfo.InvariantCulture); this.cbTargetTimeUnit.SelectedIndex = this._jsonIni.ReadInt("ProcessTimeUnit", null, 0); this.chkEnableEndScale.Checked = this._jsonIni.ReadBool("ProcessHasEndScale", null, false); this.txtEndScale.Text = this._jsonIni.ReadFloat("ProcessEndScale", null, 0.1).ToString(CultureInfo.InvariantCulture); this.chkResetScaleGradually.Checked = this._jsonIni.ReadBool("ResetGradually", null, true); this.chkResetWorldScale.Checked = this._jsonIni.ReadBool("ResetWorldScale", null, true); this.chkEnableEndScale_CheckedChanged(null, new EventArgs()); this.chkResetScaleGradually.CheckedChanged += SaveCheckImmediate; this.chkResetWorldScale.CheckedChanged += SaveCheckImmediate; this._oculusWrapper = null; if (vrMode != VRMode.OpenVR) { try { _oculusWrapper = new OculusTouchWrapper(); this._vrAvailable = true; } catch (Exception ex) { _oculusWrapper = null; this._vrAvailable = false; } } if (vrMode != VRMode.Oculus) { if (this._oculusWrapper == null) { try { this._openVRWrapper = new OpenVRWrapper(); this._vrAvailable = true; } catch (Exception ex) { //MessageBox.Show("Err 3: " + ex.Message); this._openVRWrapper = null; this._vrAvailable = false; } } } if (this._vrAvailable) { if (this._openVRWrapper != null) { this._vrWrapper = this._openVRWrapper; } else if (this._oculusWrapper != null) { this._vrWrapper = this._oculusWrapper; } } if (this._oculusWrapper != null) { this.gbScaleReset.Text += " (Hold B or Y to activate)"; } else if (this._openVRWrapper != null) { this.gbScaleReset.Text += " (Hold both grips at the same time to activate)"; } this.chkResetWorldScale.Enabled = this._vrAvailable; this.chkResetScaleGradually.Enabled = this._vrAvailable; this._frmCurrentHeight = new FrmCurrentHeight(); this._scaleCalculator = new ScaleOverTimeCalculator(this._frmCurrentHeight.lblMultiplicationTime); this._scaleCalculator.Completed += ScaleProgessCompleted; this._scaleResetManager = new ScaleOverTimeCalculator(null); _threadEnd = false; _hasBeenCapturing = false; _playerScale = 1.0f; _memEditor = new MemEditor64("GalGun2-Win64-Shipping.exe"); this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); try { this._patchManager = new AssemblyPatchManager(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); return; } }
/// <summary> /// Default values /// </summary> protected override void DefaultValues() { base.DefaultValues(); this.Monoscopic = false; this.platform = WaveServices.Platform; this.nearPlane = 0.05f; this.farPlane = 500f; this.clearFlags = ClearFlags.All; this.backgroundColor = Color.Transparent; this.VRMode = VRMode.HmdMode; }
// Use this for initialization void Awake() { vrMode = VRMode.VROff; DontDestroyOnLoad(gameObject); InvokeRepeating("toggle", 5f, 5f); }