private void activateEventSystem(WVR_DeviceType type, bool enabled) { if (EventSystem.current == null) { EventSystem _es = FindObjectOfType <EventSystem>(); if (_es != null) { eventSystem = _es.gameObject; } } else { eventSystem = EventSystem.current.gameObject; } if (eventSystem != null) { WaveVR_ControllerInputModule wcim = eventSystem.GetComponent <WaveVR_ControllerInputModule>(); if (wcim != null) { if (type == WVR_DeviceType.WVR_DeviceType_Controller_Right) { wcim.DomintEventEnabled = enabled; PrintDebugLog("Forced set DomintEventEnabled to " + wcim.DomintEventEnabled); } else if (type == WVR_DeviceType.WVR_DeviceType_Controller_Left) { wcim.NoDomtEventEnabled = enabled; PrintDebugLog("Forced set NoDomtEventEnabled to " + wcim.NoDomtEventEnabled); } } } }
public void OnPointerClick(PointerEventData eventData) { if (EventSystem.current == null) { EventSystem _es = FindObjectOfType <EventSystem> (); if (_es != null) { this.eventSystem = _es.gameObject; } } else { this.eventSystem = EventSystem.current.gameObject; } WaveVR_ControllerInputModule _cim = null; if (this.eventSystem != null) { _cim = this.eventSystem.GetComponent <WaveVR_ControllerInputModule> (); if (_cim != null) { this.raycastMode = _cim.RaycastMode; } } GameObject _go = eventData.enterEventCamera.gameObject; if (_go != null) { Log.d(LOG_TAG, "OnPointerClick() " + _go.name); switch (this.raycastMode) { case WaveVR_ControllerInputModule.ERaycastMode.Mouse: WaveVR_PointerCameraTracker _pct = _go.GetComponent <WaveVR_PointerCameraTracker> (); if (_pct != null && _cim != null) { Log.d(LOG_TAG, "OnPointerClick() set beam length of " + _pct.type + " to " + this.length); _cim.ChangeBeamLength(_pct.type, this.length); } break; case WaveVR_ControllerInputModule.ERaycastMode.Fixed: WaveVR_ControllerPointer _cp = _go.GetComponent <WaveVR_ControllerPointer> (); if (_cp != null && _cim != null) { Log.d(LOG_TAG, "OnPointerClick() set beam length of " + _cp.device + " to " + this.length); _cim.ChangeBeamLength(_cp.device, this.length); } break; // Do nothing in beam mode case WaveVR_ControllerInputModule.ERaycastMode.Beam: default: break; } } }
void Start() { if (EventSystem.current == null) { EventSystem _es = FindObjectOfType <EventSystem> (); if (_es != null) { eventSystem = _es.gameObject; PrintDebugLog("Start() find current EventSystem: " + eventSystem.name); } if (eventSystem == null) { PrintDebugLog("Start() could not find EventSystem, create new one."); eventSystem = new GameObject("EventSystem", typeof(EventSystem)); } } else { eventSystem = EventSystem.current.gameObject; } // Standalone Input Module StandaloneInputModule _sim = eventSystem.GetComponent <StandaloneInputModule> (); if (_sim != null) { _sim.enabled = false; } // Old GazeInputModule GazeInputModule _gim = eventSystem.GetComponent <GazeInputModule>(); if (_gim != null) { Destroy(_gim); } // Gaze Input Module gazeInputModule = eventSystem.GetComponent <WaveVR_GazeInputModule> (); // Controller Input Module controllerInputModule = eventSystem.GetComponent <WaveVR_ControllerInputModule> (); initInteractionModeAndGazeTriggerType(); if (!this.EnableInputModule) { disableAllInputModules(); } }
private void CreateControllerInputModule() { if (controllerInputModule == null) { // Before initializing variables of input modules, disable EventSystem to prevent the OnEnable() of input modules being executed. eventSystem.SetActive(false); controllerInputModule = eventSystem.AddComponent <WaveVR_ControllerInputModule> (); SetControllerInputModuleParameters(); // Enable EventSystem after initializing input modules. eventSystem.SetActive(true); } }
// Update is called once per frame void Update() { if (WaveVR_InputModuleManager.Instance != null && this.eventSystem == null) { setEventSystem(); } if (this.eventSystem != null) { WaveVR_ControllerInputModule _cim = this.eventSystem.GetComponent <WaveVR_ControllerInputModule> (); if (_cim != null && _cim.UnityMouseMode == false) { _cim.UnityMouseMode = true; } } }
private bool getEventSystemParameter(WVR_DeviceType type) { bool ret = false; if (EventSystem.current == null) { EventSystem _es = FindObjectOfType <EventSystem>(); if (_es != null) { eventSystem = _es.gameObject; } } else { eventSystem = EventSystem.current.gameObject; } if (eventSystem != null) { WaveVR_ControllerInputModule wcim = eventSystem.GetComponent <WaveVR_ControllerInputModule>(); if (wcim != null) { if (type == WVR_DeviceType.WVR_DeviceType_Controller_Right) { ret = wcim.DomintEventEnabled; PrintDebugLog("getEventSystemParameter() DomintEventEnabled is " + ret); } else if (type == WVR_DeviceType.WVR_DeviceType_Controller_Left) { ret = wcim.NoDomtEventEnabled; PrintDebugLog("getEventSystemParameter() NoDomtEventEnabled is " + ret); } } } return(ret); }
void Start() { if (EventSystem.current == null) { EventSystem _es = FindObjectOfType <EventSystem> (); if (_es != null) { eventSystem = _es.gameObject; DEBUG("Start() find current EventSystem: " + eventSystem.name); } if (eventSystem == null) { DEBUG("Start() could not find EventSystem, create new one."); eventSystem = new GameObject("EventSystem", typeof(EventSystem)); } } else { eventSystem = EventSystem.current.gameObject; } // Standalone Input Module StandaloneInputModule _sim = eventSystem.GetComponent <StandaloneInputModule> (); if (_sim != null) { _sim.enabled = false; } // Old GazeInputModule GazeInputModule _gim = eventSystem.GetComponent <GazeInputModule>(); if (_gim != null) { Destroy(_gim); } // Gaze Input Module gazeInputModule = eventSystem.GetComponent <WaveVR_GazeInputModule> (); WaveVR_Reticle gazePointer = gameObject.GetComponentInChildren <WaveVR_Reticle> (); if (gazePointer != null) { gazePointerRenderer = gazePointer.gameObject.GetComponent <MeshRenderer> (); DEBUG("Start() found " + gazePointer.gameObject.name); } RingMeshDrawer ringMesh = gameObject.GetComponentInChildren <RingMeshDrawer> (); if (ringMesh != null) { gazeRingRenderer = ringMesh.gameObject.GetComponent <MeshRenderer> (); DEBUG("Start() found " + gazePointer.gameObject.name); } ActivateGazePointer(false); // disable reticle // Controller Input Module controllerInputModule = eventSystem.GetComponent <WaveVR_ControllerInputModule> (); initInteractionModeAndGazeTriggerType(); if (!this.EnableInputModule) { disableAllInputModules(); } }
void Start() { if (EventSystem.current == null) { EventSystem _es = FindObjectOfType <EventSystem> (); if (_es != null) { eventSystem = _es.gameObject; PrintDebugLog("Start() find current EventSystem: " + eventSystem.name); } if (eventSystem == null) { PrintDebugLog("Start() could not find EventSystem, create new one."); eventSystem = new GameObject("EventSystem", typeof(EventSystem)); eventSystem.AddComponent <GazeInputModule> (); } } else { eventSystem = EventSystem.current.gameObject; } // Standalone Input Module StandaloneInputModule _sim = eventSystem.GetComponent <StandaloneInputModule> (); if (_sim != null) { _sim.enabled = false; } // Gaze Input Module gazeInputModule = eventSystem.GetComponent <GazeInputModule> (); if (Gaze.EnableGaze) { if (gazeInputModule == null) { CreateGazeInputModule(); } else { SetGazeInputModuleParameters(); } } else { // Deactivate gaze pointer to prevent showing pointer in scene. ActivateGazePointer(false); } // Controller Input Module controllerInputModule = eventSystem.GetComponent <WaveVR_ControllerInputModule> (); if (Controller.EnableController) { if (controllerInputModule == null) { CreateControllerInputModule(); } else { SetControllerInputModuleParameters(); } } }