Inheritance: BaseInputModule
コード例 #1
0
    protected virtual void ConfigureEventSystem()
    {
        if (!cachedEventSystem)
        {
            cachedEventSystem = FindObjectOfType <EventSystem>();
        }

        if (!cachedVRInputModule)
        {
            cachedVRInputModule = SetEventSystem(cachedEventSystem);
        }

        if (cachedEventSystem && cachedVRInputModule)
        {
            if (pointerEventData == null)
            {
                pointerEventData = new PointerEventData(cachedEventSystem);
            }

            if (!cachedVRInputModule.pointers.Contains(this))
            {
                cachedVRInputModule.pointers.Add(this);
            }
        }
    }
コード例 #2
0
ファイル: VRInputModule.cs プロジェクト: johnjoemcbob/Stellar
    protected override void Awake()
    {
        base.Awake();

        Instance = this;

        Data = new PointerEventData(eventSystem);
    }
コード例 #3
0
        // No guarantee of getting stockRumbleStrength, depends of when it's called (meant to be called at startup)
        public static void InitializeRumbleStrengthStuff(VRInputModule vrinmod)
        {
            if (!NalunaRumbleModeDetected && !m_fVanillaStockRumbleStrength.HasValue)
            {
                HapticPresetSO hapticPreset = vrinmod.GetField <HapticPresetSO, VRInputModule>("_rumblePreset");
                m_fVanillaStockRumbleStrength = hapticPreset._strength;
            }

            m_fRumbleStrength = StockRumbleStrength;
        }
コード例 #4
0
ファイル: FPFCToggle.cs プロジェクト: nicoco007/SiraUtil
        public void Refresh()
        {
            _firstPersonFlyingController = Resources.FindObjectsOfTypeAll <FirstPersonFlyingController>().FirstOrDefault();
            _vrInputModule = _firstPersonFlyingController.GetField <VRInputModule, FirstPersonFlyingController>("_vrInputModule");
            _vrInputModule.transform.SetParent(transform);
            _firstPersonFlyingController.transform.SetParent(transform);

            _firstPersonFlyingController.SetField("_cameraFov", _options.CameraFOV);
            _firstPersonFlyingController.SetField("_moveSensitivity", _options.MoveSensitivity);
            _firstPersonFlyingController.GetField <Camera, FirstPersonFlyingController>("_camera").fieldOfView = _options.CameraFOV;
        }
コード例 #5
0
ファイル: VRRayCaster.cs プロジェクト: gpsnmeajp/Oredayo4V
 public void OnPointerEnter(PointerEventData e)
 {
     if (e is VRPointerEventData)
     {
         // Gaze has entered this canvas. We'll make it the active one so that canvas-mouse pointer can be used.
         VRInputModule inputModule = EventSystem.current.currentInputModule as VRInputModule;
         if (inputModule != null)
         {
             inputModule.activeGraphicRaycaster = this;
         }
     }
 }
コード例 #6
0
        public void Process(VRInputModule vrInputModule)
        {
            VRController offHandController = _laserPointer.OffHandController;

            if (!_laserPointer.IsInitialized || offHandController == null)
            {
                return;
            }

            BaseInputModule baseInputModule = vrInputModule as BaseInputModule;
            EventSystem     eventSystem     = EventSystemAccessor(ref baseInputModule);

            if (_pointerEventData == null)
            {
                _pointerEventData = new PointerEventData(eventSystem)
                {
                    pointerId = OffHandPointerId
                }
            }
            ;

            // perform raycast
            _pointerEventData.Reset();
            _pointerEventData.pointerCurrentRaycast = new RaycastResult
            {
                worldPosition = offHandController.position,
                worldNormal   = offHandController.forward
            };
            _pointerEventData.scrollDelta = Vector2.zero;

            eventSystem.RaycastAll(_pointerEventData, _raycastResults);

            // reimplementation of FindFirstRaycast
            _pointerEventData.pointerCurrentRaycast = default;
            for (int i = 0; i < _raycastResults.Count; ++i)
            {
                if (_raycastResults[i].gameObject != null)
                {
                    _pointerEventData.pointerCurrentRaycast = _raycastResults[i];
                    break;
                }
            }

            _pointerEventData.delta    = _pointerEventData.pointerCurrentRaycast.screenPosition - _pointerEventData.position;
            _pointerEventData.position = _pointerEventData.pointerCurrentRaycast.screenPosition;

            // handle pointer enter/exit on gameobjects
            HandlePointerExitAndEnter(vrInputModule, _pointerEventData, _pointerEventData.pointerCurrentRaycast.gameObject);

            // send raycast results to laser pointer
            _laserPointer.Process(_pointerEventData);
        }
コード例 #7
0
        private static void SetHapticFeedbackController()
        {
            VRInputModule vrInputModule = Resources.FindObjectsOfTypeAll <VRInputModule>().FirstOrDefault();

            if (vrInputModule != null)
            {
                m_oHaptic = vrInputModule.GetField <HapticFeedbackController, VRInputModule>("_hapticFeedbackController");
            }
            else
            {
                Plugin.Log?.Error($"Couldn't find HapticFeedbackController");
            }
        }
コード例 #8
0
    protected override void OnEnable()
    {
        previousEventSystem = current;
        if (previousEventSystem != null)
        {
            previousEventSystem.enabled = false;
            CopyValuesFrom(previousEventSystem, this);
        }

        vrInputModule = gameObject.AddComponent <VRInputModule>();
        base.OnEnable();
        StartCoroutine(SetEventSystemOfBaseInputModulesAfterFrameDelay(this));
    }
コード例 #9
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (target != null)
     {
         if (source == null)
         {
             RawImage rawImage = GetComponent <RawImage>();
             source  = rawImage.texture;
             m_Color = rawImage.color;
         }
         target.texture = source;
         target.color   = m_Color;
         VRInputModule.TriggerVibration(eventData, vibrationTime);
     }
 }
コード例 #10
0
            private static void Postfix(VRInputModule __instance)
            {
                try
                {
                    ProcessHook?.Invoke(__instance);
                }
                catch (Exception e)
                {
                    Logger.log.Error("Exception thrown in VRInputModule Process hook. Removing harmony patch to prevent further exceptions");
                    Logger.log.Debug(e);

                    var harmony = new Harmony(Plugin.HarmonyId);
                    harmony.Unpatch(typeof(VRInputModule).GetMethod("Process"), HarmonyPatchType.Postfix, Plugin.HarmonyId);
                }
            }
コード例 #11
0
ファイル: SSVRTrace.cs プロジェクト: Farl/SSCore2017
    // Update is called once per frame
    void Update()
    {
        Ray        viewRay = GetComponent <Camera>().ViewportPointToRay(new Vector3(0.5f, 0.5f));
        RaycastHit hitInfo;

        Debug.DrawRay(viewRay.origin, viewRay.direction);
        if (Physics.Raycast(viewRay.origin, viewRay.direction, out hitInfo, 1000f))
        {
            VRInputModule.SetTargetObject(hitInfo.collider.gameObject);
        }
        else
        {
            VRInputModule.SetTargetObject(null);
        }
    }
コード例 #12
0
        // Update is called once per frame
        void Update()
        {
            Vector3 thisPosition;

            thisPosition.x = Input.mousePosition.x * xSens;
            thisPosition.y = Input.mousePosition.y * ySens - 1;
            thisPosition.z = transform.position.z;

            transform.position = thisPosition;

            VRInputModule.cursorPosition = transform.position;

            if (Input.GetMouseButtonDown(0) && currentCollider)
            {
                VRInputModule.PointerSubmit(currentCollider.gameObject);
            }
        }
コード例 #13
0
 /// <summary>
 /// Refreshes the FPFC Variables.
 /// </summary>
 public void Refresh()
 {
     _firstPersonFlyingController = Resources.FindObjectsOfTypeAll <FirstPersonFlyingController>().FirstOrDefault();
     _vrInputModule = _firstPersonFlyingController.GetField <VRInputModule, FirstPersonFlyingController>("_vrInputModule");
     _camera        = _firstPersonFlyingController.GetField <Camera, FirstPersonFlyingController>("_camera");
     _vrInputModule.transform.SetParent(transform);
     if (_originalOriginLocation == null)
     {
         _originalOriginLocation = _firstPersonFlyingController.transform;
     }
     if (_helper.currentXRDeviceModel == XRDeviceModel.Unknown)
     {
         _camera.fieldOfView = _options.CameraFOV;
     }
     _firstPersonFlyingController.transform.SetParent(transform);
     _firstPersonFlyingController.SetField("_cameraFov", _options.CameraFOV);
     _firstPersonFlyingController.SetField("_moveSensitivity", _options.MoveSensitivity);
     _leftController  = _firstPersonFlyingController.GetField <VRController, FirstPersonFlyingController>("_controller0");
     _rightController = _firstPersonFlyingController.GetField <VRController, FirstPersonFlyingController>("_controller1");
 }
コード例 #14
0
ファイル: FPFCToggle.cs プロジェクト: ErisApps/SiraUtil
        public void Toggle(bool state)
        {
            if (_firstPersonFlyingController == null)
            {
                _firstPersonFlyingController = Resources.FindObjectsOfTypeAll <FirstPersonFlyingController>().FirstOrDefault();
                _vrInputModule = _firstPersonFlyingController.GetField <VRInputModule, FirstPersonFlyingController>("_vrInputModule");
                _vrInputModule.transform.SetParent(transform);
                _firstPersonFlyingController.transform.SetParent(transform);

                _firstPersonFlyingController.SetField("_cameraFov", _cameraFOV);
                _firstPersonFlyingController.SetField("_moveSensitivity", _moveSensitivity);
                _firstPersonFlyingController.GetField <Camera, FirstPersonFlyingController>("_camera").fieldOfView = _cameraFOV;
            }

            _vrInputModule.enabled = state;
            _vrInputModule.gameObject.SetActive(true);
            _firstPersonFlyingController.enabled = state;
            Cursor.lockState = state ? CursorLockMode.Locked : CursorLockMode.None;
            Cursor.visible   = !state;
            Enabled          = state;
        }
コード例 #15
0
    public void UpdatesSceneCanvases()
    {
        //UI_dummyCamera = transform.Find("VRCamera/VR_UI_dummyCamera").GetComponent<Camera>();
        UI_dummyCamera = transform.Find("VRCamera/Main Camera").GetComponent <Camera>();
        GameObject eventSystem = null;

        if (GameObject.FindObjectOfType <EventSystem>() != null)
        {
            eventSystem = GameObject.FindObjectOfType <EventSystem>().gameObject;
        }
        if (eventSystem != null)
        {
            if (eventSystem.GetComponent <VRInputModule>() == null)
            {
                if (eventSystem.GetComponent <StandaloneInputModule>() != null)
                {
                    eventSystem.GetComponent <StandaloneInputModule>().enabled = false;
                }
                if (eventSystem.GetComponent <TouchInputModule>() != null)
                {
                    eventSystem.GetComponent <TouchInputModule>().enabled = false;
                }
                VRInputModule vrim = eventSystem.AddComponent <VRInputModule>();
                vrim.enabled         = true;
                vrim.timeToLookPress = lookToPressTime;
                vrim.SetProgressBarTexture(defaultProgressBarTex);
                vrim.SetVRpointerTexture(defaultPointerTex);
            }
            Canvas[] cvs = GameObject.FindObjectsOfType <Canvas>();
            for (int k = 0; k < cvs.Length; k++)
            {
                if (cvs[k].renderMode == RenderMode.WorldSpace)
                {
                    cvs[k].worldCamera = UI_dummyCamera;
                }
            }
        }
    }
コード例 #16
0
 private void Start()
 {
     m_InputModule = EventSystem.current.gameObject.GetComponent <VRInputModule>();
 }
コード例 #17
0
	void Awake() {
		_singleton = this;
	}
コード例 #18
0
 void OnTriggerExit(Collider other)
 {
     //print("OnTriggerExit other " + other.gameObject);
     VRInputModule.PointerExit(other.gameObject);
     currentCollider = null;
 }
コード例 #19
0
 void OnTriggerEnter(Collider other)
 {
     //print("OnTriggerEnter other " + other.gameObject);
     VRInputModule.PointerEnter(other.gameObject);
     currentCollider = other;
 }
コード例 #20
0
 void Awake()
 {
     _singleton = this;
 }
コード例 #21
0
ファイル: Pointer.cs プロジェクト: GLovett19/NeonHighway
 private void Start()
 {
     // current.currentInputModule does not work
     inputModule = EventSystem.current.gameObject.GetComponent <VRInputModule>();
 }
コード例 #22
0
ファイル: MenuGeneric.cs プロジェクト: GLovett19/NeonHighway
 private void Awake()
 {
     MyEventSystem = FindObjectOfType <EventSystem>();
     inputModule   = EventSystem.current.gameObject.GetComponent <VRInputModule>();
 }
コード例 #23
0
        // reimplementation of VRInputModule's HandlePointerExitAndEnter
        // only functional change should be that we target the off-hand controller for haptics
        private void HandlePointerExitAndEnter(VRInputModule vrInputModule, PointerEventData eventData, GameObject newEnterTarget)
        {
            if (newEnterTarget == null || eventData.pointerEnter == null)
            {
                foreach (var hovered in eventData.hovered)
                {
                    ExecuteEvents.Execute(hovered, eventData, ExecuteEvents.pointerExitHandler);
                }
                eventData.hovered.Clear();

                if (newEnterTarget == null)
                {
                    eventData.pointerEnter = null;
                    return;
                }
            }

            // at this point, newEnterTarget cannot be null
            if (eventData.pointerEnter == newEnterTarget)
            {
                return;
            }

            GameObject commonRoot = null;
            Transform  t          = null;

            if (eventData.pointerEnter != null)
            {
                // reimplementation of BaseInputModule.FindCommonRoot
                Transform t1    = eventData.pointerEnter.transform;
                bool      found = false;
                while (t1 != null)
                {
                    Transform t2 = newEnterTarget.transform;
                    while (t2 != null)
                    {
                        if (t1 == t2)
                        {
                            commonRoot = t1.gameObject;
                            found      = true;
                            break;
                        }

                        t2 = t2.parent;
                    }

                    if (found)
                    {
                        break;
                    }
                    else
                    {
                        t1 = t1.parent;
                    }
                }

                t = eventData.pointerEnter.transform;
                while (t != null && commonRoot?.transform != t)
                {
                    ExecuteEvents.Execute(t.gameObject, eventData, ExecuteEvents.pointerExitHandler);
                    eventData.hovered.Remove(t.gameObject);
                    t = t.parent;
                }
            }

            if (!vrInputModule.userInteractionEnabled)
            {
                return;
            }

            bool hasTriggeredHapticPulse = false;

            eventData.pointerEnter = newEnterTarget;
            t = newEnterTarget.transform;

            while (t != null && t.gameObject != commonRoot)
            {
                _componentsList.Clear();
                t.gameObject.GetComponents(_componentsList);

                if (!hasTriggeredHapticPulse)
                {
                    foreach (var component in _componentsList)
                    {
                        Selectable   selectable   = component as Selectable;
                        Interactable interactable = component as Interactable;
                        if ((selectable != null && selectable.isActiveAndEnabled && selectable.interactable) ||
                            (interactable != null && interactable.isActiveAndEnabled && interactable.interactable))
                        {
                            VRPlatformHelperAccessor(ref vrInputModule).TriggerHapticPulse(_laserPointer.OffHandController.node, 0.25f);
                            hasTriggeredHapticPulse = true;
                            break;
                        }
                    }
                }

                ExecuteEvents.Execute(t.gameObject, eventData, ExecuteEvents.pointerEnterHandler);
                eventData.hovered.Add(t.gameObject);
                t = t.parent;
            }
        }
コード例 #24
0
 public void OnPointerEnter(PointerEventData eventData)
 {
     VRInputModule.TriggerVibration(eventData, vibrationTime);
 }
コード例 #25
0
ファイル: VRInputModule.cs プロジェクト: Farl/SSCore2017
 protected override void Awake()
 {
     base.Awake();
     _singleton = this;
 }
コード例 #26
0
 private void Awake()
 {
     PinterInputModule = GetComponent <VRInputModule>();
 }
コード例 #27
0
 protected override void Awake()
 {
     base.Awake();
     instance = this;
 }