private float debugFrameTimeoutValue = 0.1f; // sec. /// <summary> /// Start this instance. /// Note: make sure to always have a Start function for classes that have editor scripts. /// </summary> void Start() { // Add a listener to the OVRMessenger for touch events OVRMessenger.AddListener <OVRTouchpad.TouchEvent>("Touchpad", LocalTouchEventCallback); }
/// <summary> /// Start this instance. /// Note: make sure to always have a Start function for classes that have editor scripts. /// </summary> void Start() { // Create the context that we will feed into the audio buffer lock (this) { if (context == 0) { if (OVRLipSync.CreateContext(ref context, provider) != OVRLipSync.ovrLipSyncSuccess) { Debug.Log("OVRPhonemeContext.Start ERROR: Could not create Phoneme context."); return; } } } // OVRLipSyncDebugConsole.Clear (); // OVRLipSyncDebugConsole.Log ("Welcome to the viseme demo! Use 'Left Arrow' and 'Right Arrow' to adjust input gain. Press 'L' to hear mic input."); // Add a listener to the OVRMessenger for touch events //AudioClip clip = Resources.Load("uni1487") as AudioClip; //Debug.Log("AudioClip"+clip.name); //transform.GetComponent<AudioSource>().clip = clip; //transform.GetComponent<AudioSource>().Play(); OVRMessenger.AddListener <OVRTouchpad.TouchEvent>("Touchpad", LocalTouchEventCallback); }
// HandleInputMouse static void HandleInputMouse(ref Vector3 move) { if (move.magnitude < minMovMagnitudeMouse) { OVRMessenger.Broadcast <TouchEvent>("Touchpad", TouchEvent.SingleTap); } else { move.Normalize(); // Left/Right if (Mathf.Abs(move.x) > Mathf.Abs(move.y)) { if (move.x > 0.0f) { OVRMessenger.Broadcast <TouchEvent>("Touchpad", TouchEvent.Left); } else { OVRMessenger.Broadcast <TouchEvent>("Touchpad", TouchEvent.Right); } } // Up/Down else if (move.y > 0.0f) { OVRMessenger.Broadcast <TouchEvent>("Touchpad", TouchEvent.Down); } else { OVRMessenger.Broadcast <TouchEvent>("Touchpad", TouchEvent.Up); } } }
// Token: 0x06003A3D RID: 14909 RVA: 0x00126962 File Offset: 0x00124D62 private void Start() { OVRMessenger.AddListener <OVRTouchpad.TouchEvent>("Touchpad", new OVRCallback <OVRTouchpad.TouchEvent>(this.LocalTouchEventCallback)); this.targetSet = 0; this.SwitchTargets[0].SetActive(0); this.SwitchTargets[1].SetActive(0); }
// Use this for initialization void Start () { // Add a listener to the OVRMessenger for touch events OVRMessenger.AddListener<OVRTouchpad.TouchEvent>("Touchpad", LocalTouchEventCallback): // Initialize the proper target set targetSet = 0: SwitchTargets[0].SetActive(0): SwitchTargets[1].SetActive(0): }
/// <summary> /// We can detect if our devices have been plugged or unplugged, as well as /// run things that need to be updated in our game thread /// </summary> void Update() { MessageList oldMsgList = MsgList; OVR_Update(ref MsgList); // HMD SENSOR if ((MsgList.isHMDSensorAttached != 0) && (oldMsgList.isHMDSensorAttached == 0)) { OVRMessenger.Broadcast <OVRMainMenu.Device, bool>("Sensor_Attached", OVRMainMenu.Device.HMDSensor, true); //Debug.Log("HMD SENSOR ATTACHED"); } else if ((MsgList.isHMDSensorAttached == 0) && (oldMsgList.isHMDSensorAttached != 0)) { OVRMessenger.Broadcast <OVRMainMenu.Device, bool>("Sensor_Attached", OVRMainMenu.Device.HMDSensor, false); //Debug.Log("HMD SENSOR DETACHED"); } // HMD if ((MsgList.isHMDAttached != 0) && (oldMsgList.isHMDAttached == 0)) { OVRMessenger.Broadcast <OVRMainMenu.Device, bool>("Sensor_Attached", OVRMainMenu.Device.HMD, true); //Debug.Log("HMD ATTACHED"); } else if ((MsgList.isHMDAttached == 0) && (oldMsgList.isHMDAttached != 0)) { OVRMessenger.Broadcast <OVRMainMenu.Device, bool>("Sensor_Attached", OVRMainMenu.Device.HMD, false); //Debug.Log("HMD DETACHED"); } // LATENCY TESTER if ((MsgList.isLatencyTesterAttached != 0) && (oldMsgList.isLatencyTesterAttached == 0)) { OVRMessenger.Broadcast <OVRMainMenu.Device, bool>("Sensor_Attached", OVRMainMenu.Device.LatencyTester, true); //Debug.Log("LATENCY TESTER ATTACHED"); } else if ((MsgList.isLatencyTesterAttached == 0) && (oldMsgList.isLatencyTesterAttached != 0)) { OVRMessenger.Broadcast <OVRMainMenu.Device, bool>("Sensor_Attached", OVRMainMenu.Device.LatencyTester, false); //Debug.Log("LATENCY TESTER DETACHED"); } // Update prediction if being changed from outside PredictionTime = GetPredictionTime(); }
// Use this for initialization void Start () { // Add a listener to the OVRMessenger for touch events OVRMessenger.AddListener<OVRTouchpad.TouchEvent>("Touchpad", LocalTouchEventCallback): // Initialize the proper target set targetSet = 0: SwitchTarget.SetActive(0): // Set initial color on models if(material != null) material.SetColor("_Color", Color.grey): }
// Token: 0x06003A75 RID: 14965 RVA: 0x00127458 File Offset: 0x00125858 public static void Broadcast <T, U, V>(string eventType, T arg1, U arg2, V arg3) { OVRMessenger.OnBroadcasting(eventType); Delegate @delegate; if (OVRMessenger.eventTable.TryGetValue(eventType, out @delegate)) { OVRCallback <T, U, V> ovrcallback = @delegate as OVRCallback <T, U, V>; if (ovrcallback == null) { throw OVRMessenger.CreateBroadcastSignatureException(eventType); } ovrcallback(arg1, arg2, arg3); } }
// Token: 0x06003A72 RID: 14962 RVA: 0x00127384 File Offset: 0x00125784 public static void Broadcast(string eventType) { OVRMessenger.OnBroadcasting(eventType); Delegate @delegate; if (OVRMessenger.eventTable.TryGetValue(eventType, out @delegate)) { OVRCallback ovrcallback = @delegate as OVRCallback; if (ovrcallback == null) { throw OVRMessenger.CreateBroadcastSignatureException(eventType); } ovrcallback(); } }
/// <summary> /// Start this instance. /// Note: make sure to always have a Start function for classes that have editor scripts. /// </summary> void Start() { // Create the context that we will feed into the audio buffer lock (this) { if (context == 0) { if (OVRLipSync.CreateContext(ref context, provider) != OVRLipSync.ovrLipSyncSuccess) { Debug.Log("OVRPhonemeContext.Start ERROR: Could not create Phoneme context."); return; } } } // OVRLipSyncDebugConsole.Clear (); // OVRLipSyncDebugConsole.Log ("Welcome to the viseme demo! Use 'Left Arrow' and 'Right Arrow' to adjust input gain. Press 'L' to hear mic input."); // Add a listener to the OVRMessenger for touch events OVRMessenger.AddListener <OVRTouchpad.TouchEvent>("Touchpad", LocalTouchEventCallback); }
/// <summary> /// Start this instance. /// Note: make sure to always have a Start function for classes that have editor scripts. /// </summary> void Start() { // Create the context that we will feed into the audio buffer lock (this) { if (context == 0) { if (OVRVoiceMod.CreateContext(ref context) != OVRVoiceMod.ovrVoiceModSuccess) { Debug.Log("OVRVoiceModContext.Start ERROR: Could not create VoiceMod context."); return; } } } // Add a listener to the OVRMessenger for touch events OVRMessenger.AddListener <OVRTouchpad.TouchEvent>("Touchpad", LocalTouchEventCallback); // VoiceMod: Set the current state of the voice mod as set in the inspector SendVoiceModUpdate(); }
// Token: 0x06003A6D RID: 14957 RVA: 0x00127281 File Offset: 0x00125681 public static void AddListener <T, U, V>(string eventType, OVRCallback <T, U, V> handler) { OVRMessenger.OnListenerAdding(eventType, handler); OVRMessenger.eventTable[eventType] = (OVRCallback <T, U, V>)Delegate.Combine((OVRCallback <T, U, V>)OVRMessenger.eventTable[eventType], handler); }
// Start void Start() { AlphaFadeValue = 1.0f; CurrentLevel = 0; PrevStartDown = false; PrevHatDown = false; PrevHatUp = false; ShowVRVars = false; OldSpaceHit = false; strFPS = "FPS: 0"; LoadingLevel = false; ScenesVisible = false; // Ensure that camera controller variables have been properly // initialized before we start reading them if (CameraController != null) { CameraController.InitCameraControllerVariables(); GuiHelper.SetCameraController(ref CameraController); } // Set the GUI target GUIRenderObject = GameObject.Instantiate(Resources.Load("OVRGUIObjectMain")) as GameObject; if (GUIRenderObject != null) { if (GUIRenderTexture == null) { int w = Screen.width; int h = Screen.height; if (CameraController.PortraitMode == true) { int t = h; h = w; w = t; } GUIRenderTexture = new RenderTexture(w, h, 24); GuiHelper.SetPixelResolution(w, h); GuiHelper.SetDisplayResolution(OVRDevice.HResolution, OVRDevice.VResolution); } } // Attach GUI texture to GUI object and GUI object to Camera if (GUIRenderTexture != null && GUIRenderObject != null) { GUIRenderObject.renderer.material.mainTexture = GUIRenderTexture; if (CameraController != null) { // Grab transform of GUI object Transform t = GUIRenderObject.transform; // Attach the GUI object to the camera CameraController.AttachGameObjectToCamera(ref GUIRenderObject); // Reset the transform values (we will be maintaining state of the GUI object // in local state) OVRUtils.SetLocalTransform(ref GUIRenderObject, ref t); // Deactivate object until we have completed the fade-in // Also, we may want to deactive the render object if there is nothing being rendered // into the UI // we will move the position of everything over to the left, so get // IPD / 2 and position camera towards negative X Vector3 lp = GUIRenderObject.transform.localPosition; float ipd = 0.0f; CameraController.GetIPD(ref ipd); lp.x -= ipd * 0.5f; GUIRenderObject.transform.localPosition = lp; GUIRenderObject.SetActive(false); } } // Save default values initially StoreSnapshot("DEFAULT"); // Make sure to hide cursor if (Application.isEditor == false) { Screen.showCursor = false; Screen.lockCursor = true; } // Add delegates to update; useful for ordering menu tasks, if required UpdateFunctions += UpdateFPS; // CameraController updates if (CameraController != null) { UpdateFunctions += UpdateIPD; UpdateFunctions += UpdatePrediction; UpdateFunctions += UpdateFOV; UpdateFunctions += UpdateDistortionCoefs; UpdateFunctions += UpdateEyeHeightOffset; } // PlayerController updates if (PlayerController != null) { UpdateFunctions += UpdateSpeedAndRotationScaleMultiplier; UpdateFunctions += UpdatePlayerControllerMovement; } // MainMenu updates UpdateFunctions += UpdateSelectCurrentLevel; UpdateFunctions += UpdateHandleSnapshots; // Device updates UpdateFunctions += UpdateDeviceDetection; UpdateFunctions += UpdateResetOrientation; OVRMessenger.AddListener <Device, bool>("Sensor_Attached", UpdateDeviceDetectionMsgCallback); // Mag Yaw-Drift correction UpdateFunctions += MagCal.UpdateMagYawDriftCorrection; MagCal.SetOVRCameraController(ref CameraController); // Crosshair functionality Crosshair.Init(); Crosshair.SetCrosshairTexture(ref CrosshairImage); Crosshair.SetOVRCameraController(ref CameraController); Crosshair.SetOVRPlayerController(ref PlayerController); UpdateFunctions += Crosshair.UpdateCrosshair; // Check for HMD and sensor CheckIfRiftPresent(); // Init static members ScenesVisible = false; }
//Clean up eventTable every time a new level loads. public void OnDisable() { OVRMessenger.Cleanup(); }
// Start void Start() { AlphaFadeValue = 1.0f; CurrentLevel = 0; PrevStartDown = false; PrevHatDown = false; PrevHatUp = false; ShowVRVars = false; OldSpaceHit = false; strFPS = "FPS: 0"; LoadingLevel = false; sShowLevels = false; // Ensure that camera controller variables have been properly // initialized before we start reading them if (CameraController != null) { CameraController.InitCameraControllerVariables(); } // Attach GUI texture to GUI object and GUI object to Camera if (GUIRenderTexture != null && GUIRenderObject != null) { GUIRenderObject.renderer.material.mainTexture = GUIRenderTexture; if (CameraController != null) { // Grab transform of GUI object Transform t = GUIRenderObject.transform; // Attach the GUI object to the camera CameraController.AttachGameObjectToCamera(ref GUIRenderObject); // Reset the transform values (we will be maintaining state of the GUI object // in local state) OVRUtils.SetLocalTransform(ref GUIRenderObject, ref t); // Deactivate object until we have completed the fade-in // Also, we may want to deactive the render object if there is nothing being rendered // into the UI GUIRenderObject.SetActive(false); } } // Save default values initially StoreSnapshot("DEFAULT"); // Make sure to hide cursor //Screen.showCursor = false; //Screen.lockCursor = true; // Add delegates to update; useful for ordering menu tasks, if required UpdateFunctions += UpdateFPS; // CameraController updates if (CameraController != null) { UpdateFunctions += UpdateIPD; UpdateFunctions += UpdatePrediction; UpdateFunctions += UpdateFOV; UpdateFunctions += UpdateDistortionCoefs; UpdateFunctions += UpdateHeightOffset; } // PlayerController updates if (PlayerController != null) { UpdateFunctions += UpdateSpeedAndRotationScaleMultiplier; } // MainMenu updates UpdateFunctions += UpdateSelectCurrentLevel; UpdateFunctions += UpdateHandleSnapshots; // Device updates UpdateFunctions += UpdateDeviceDetection; UpdateFunctions += UpdateResetOrientation; OVRMessenger.AddListener <Device, bool>("Sensor_Attached", UpdateDeviceDetectionMsgCallback); // Mag Yaw-Drift correction UpdateFunctions += MagCal.UpdateMagYawDriftCorrection; MagCal.SetOVRCameraController(ref CameraController); // Check for HMD and sensor CheckIfRiftPresent(); // Init static members sShowLevels = false; }
// Token: 0x06003A71 RID: 14961 RVA: 0x0012734F File Offset: 0x0012574F public static void RemoveListener <T, U, V>(string eventType, OVRCallback <T, U, V> handler) { OVRMessenger.OnListenerRemoving(eventType, handler); OVRMessenger.eventTable[eventType] = (OVRCallback <T, U, V>)Delegate.Remove((OVRCallback <T, U, V>)OVRMessenger.eventTable[eventType], handler); OVRMessenger.OnListenerRemoved(eventType); }
/// <summary> /// Start this instance. /// </summary> void Start() { AlphaFadeValue = 1.0f; CurrentLevel = 0; PrevStartDown = false; PrevHatDown = false; PrevHatUp = false; ShowVRVars = false; OldSpaceHit = false; strFPS = "FPS: 0"; LoadingLevel = false; ScenesVisible = false; // Ensure that camera controller variables have been properly // initialized before we start reading them if (CameraController != null) { CameraController.InitCameraControllerVariables(); } // Set the GUI target GUIRenderObject = GameObject.Instantiate(Resources.Load("OVRGUIObjectMain")) as GameObject; if (GUIRenderObject != null) { // Chnge the layer GUIRenderObject.layer = LayerMask.NameToLayer(LayerName); if (GUIRenderTexture == null) { int w = Screen.width; int h = Screen.height; // We don't need a depth buffer on this texture GUIRenderTexture = new RenderTexture(w, h, 0); GuiHelper.SetPixelResolution(w, h); // NOTE: All GUI elements are being written with pixel values based // from DK1 (1280x800). These should change to normalized locations so // that we can scale more cleanly with varying resolutions //GuiHelper.SetDisplayResolution(OVRDevice.HResolution, // OVRDevice.VResolution); GuiHelper.SetDisplayResolution(1280.0f, 800.0f); } } // Attach GUI texture to GUI object and GUI object to Camera if (GUIRenderTexture != null && GUIRenderObject != null) { GUIRenderObject.renderer.material.mainTexture = GUIRenderTexture; if (CameraController != null) { // Grab transform of GUI object Transform t = GUIRenderObject.transform; // Attach the GUI object to the camera CameraController.AttachGameObjectToCamera(ref GUIRenderObject); // Reset the transform values (we will be maintaining state of the GUI object // in local state) OVRUtils.SetLocalTransform(ref GUIRenderObject, ref t); // Deactivate object until we have completed the fade-in // Also, we may want to deactive the render object if there is nothing being rendered // into the UI // we will move the position of everything over to the left, so get // IPD / 2 and position camera towards negative X Vector3 lp = GUIRenderObject.transform.localPosition; float ipd = 0.0f; CameraController.GetIPD(ref ipd); lp.x -= ipd * 0.5f; GUIRenderObject.transform.localPosition = lp; GUIRenderObject.SetActive(false); } } // Save default values initially StoreSnapshot("DEFAULT"); // Make sure to hide cursor if (Application.isEditor == false) { Screen.showCursor = false; Screen.lockCursor = true; } // Add delegates to update; useful for ordering menu tasks, if required UpdateFunctions += UpdateFPS; // CameraController updates if (CameraController != null) { UpdateFunctions += UpdateIPD; UpdateFunctions += UpdatePrediction; // Set LPM on by default UpdateFunctions += UpdateLowPersistanceMode; OVRDevice.SetLowPersistanceMode(LowPersistanceMode); UpdateFunctions += UpdateVisionMode; UpdateFunctions += UpdateFOV; UpdateFunctions += UpdateEyeHeightOffset; // Add a GridCube component to this object GridCube = gameObject.AddComponent <OVRGridCube>(); GridCube.SetOVRCameraController(ref CameraController); // Add a VisionGuide component to this object VisionGuide = gameObject.AddComponent <OVRVisionGuide>(); VisionGuide.SetOVRCameraController(ref CameraController); VisionGuide.SetFadeTexture(ref FadeInTexture); VisionGuide.SetVisionGuideLayer(ref LayerName); } // PlayerController updates if (PlayerController != null) { UpdateFunctions += UpdateSpeedAndRotationScaleMultiplier; UpdateFunctions += UpdatePlayerControllerMovement; } // MainMenu updates UpdateFunctions += UpdateSelectCurrentLevel; UpdateFunctions += UpdateHandleSnapshots; // Device updates UpdateFunctions += UpdateDeviceDetection; // Add a callback to detect device detection OVRMessenger.AddListener <Device, bool>("Sensor_Attached", UpdateDeviceDetectionMsgCallback); // Mag Yaw-Drift correction // We will test to see if we are already calibrated by the // Calibration tool MagCal.SetInitialCalibarationState(); UpdateFunctions += MagCal.UpdateMagYawDriftCorrection; MagCal.SetOVRCameraController(ref CameraController); // Crosshair functionality Crosshair.Init(); Crosshair.SetCrosshairTexture(ref CrosshairImage); Crosshair.SetOVRCameraController(ref CameraController); Crosshair.SetOVRPlayerController(ref PlayerController); UpdateFunctions += Crosshair.UpdateCrosshair; // Check for HMD and sensor CheckIfRiftPresent(); // Reset tracker position. // We assume that the CameraController is at the desired neck location Vector3 eyeOffset = Vector3.zero; if (CameraController != null) { CameraController.GetEyeCenterPosition(ref eyeOffset); } OVRCamera.ResetCameraPositionOrientation(ref eyeOffset, true, false, false); }