Exemplo n.º 1
0
 private void TryMoveGrab(XRController controller, XRRayInteractor interactor)
 {
     if (m_target != null && m_target.IsValid && IsOwner(controller) && m_style == GrabStyle.Laser)
     {
         TryMoveTo(interactor);
     }
 }
Exemplo n.º 2
0
 private void SecondaryHold(XRController controller, XRRayInteractor interactor)
 {
     if (controller.controllerNode == hand)
     {
         m_buttons |= MouseButton.Right;
     }
 }
        void Start()
        {
            if (m_XrRig == null)
            {
                m_XrRig = FindObjectOfType <XRRig>();
            }

            m_XrRayInteractor        = GetComponent <XRRayInteractor>();
            m_XrInteractorLineVisual = GetComponent <XRInteractorLineVisual>();
            m_LinePoints             = new Vector3[k_MaxLinePoints];
            m_TeleportationTarget.gameObject.SetActive(false);
            m_MainCamera = Camera.main.transform;

            m_DisposeOnDestroy.Add(m_RootSelector           = UISelectorFactory.createSelector <Transform>(PipelineContext.current, nameof(IPipelineDataProvider.rootNode)));
            m_DisposeOnDestroy.Add(m_CamInfoSelector        = UISelectorFactory.createSelector <CameraTransformInfo>(ProjectContext.current, nameof(ITeleportDataProvider.cameraTransformInfo)));
            m_DisposeOnDestroy.Add(m_TeleportPickerSelector = UISelectorFactory.createSelector <IPicker>(ProjectContext.current, nameof(ITeleportDataProvider.teleportPicker),
                                                                                                         async =>
            {
                SetInitialTeleportDistance();
            }));
            m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <SetActiveToolAction.ToolType>(ToolStateContext.current, nameof(IToolStateDataProvider.activeTool),
                                                                                                   type =>
            {
                m_CanTeleport = type != SetActiveToolAction.ToolType.SelectTool;
            }));
            m_TeleportAction = m_InputActionAsset["VR/Teleport"];
            m_InputActionAsset["VR/Select"].performed += OnTeleport;
        }
Exemplo n.º 4
0
 private void PrimaryHold(XRController controller, XRRayInteractor interactor)
 {
     if (controller.controllerNode == hand)
     {
         m_buttons |= MouseButton.Left;
     }
 }
Exemplo n.º 5
0
 public MockHMDInput(XRController right, XRController left)
 {
     m_rightController = right;
     m_leftController  = left;
     m_rightHand       = right.GetComponent <XRRayInteractor>();
     m_leftHand        = left.GetComponent <XRRayInteractor>();
 }
Exemplo n.º 6
0
 private void HideRadialMenu(XRController controller, XRRayInteractor interactor)
 {
     if (controller.controllerNode == hand)
     {
         RadialMenu.Show(false);
     }
 }
Exemplo n.º 7
0
 //Function that is called everytime function Update() is called.
 private void ScreenDistanceFromGround(XRRayInteractor interactor)
 {
     if (interactor.GetCurrentRaycastHit(out var hit) && hit.transform.gameObject.CompareTag("Screen"))
     {
         CalculateDistance(hit);
     }
 }
 private void Start()
 {
     if (leftTeleportRay)
     {
         leftRayInteractor = leftTeleportRay.gameObject.GetComponent <XRRayInteractor>();
     }
 }
Exemplo n.º 9
0
 private void SetPoint(XRController controller, XRRayInteractor interactor)
 {
     if (controller.controllerNode == hand)
     {
         MeasureDistance(interactor);
     }
 }
Exemplo n.º 10
0
 void Start()
 {
     if (RightTeleportRay)
     {
         rightRayInteractorTeleport = RightTeleportRay.gameObject.GetComponent <XRRayInteractor>();
     }
 }
Exemplo n.º 11
0
 private void Clear(XRController controller, XRRayInteractor interactor)
 {
     //You could limit the clear to a certain controller by
     //comparing the current node.
     Display(false);
     m_measuring = false;
 }
Exemplo n.º 12
0
 private void TryStopGrab(XRController controller, XRRayInteractor interactor)
 {
     if (m_target != null && IsOwner(controller))
     {
         m_target.StopGrab();
     }
 }
Exemplo n.º 13
0
 private void SecondaryButtonClick(XRController controller, XRRayInteractor interactor)
 {
     if (interactor.GetCurrentRaycastHit(out var hit) &&
         hit.transform.parent != null &&
         hit.transform.parent.TryGetComponent(out VRBrowserPanel panel))
     {
         SelectDisplay(panel);
     }
Exemplo n.º 14
0
 private void UpdateScroll(XRController controller, XRRayInteractor interactor)
 {
     if (controller.controllerNode == hand &&
         controller.inputDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out var value))
     {
         m_scroll = value;
     }
 }
Exemplo n.º 15
0
 private void FindTarget(XRController controller, XRRayInteractor interactor)
 {
     if (showingText)
     {
         InfoDisplay.Instance.ClearText();
         showingText = false;
         return;
     }
     SearchCalculableObject(interactor);
 }
Exemplo n.º 16
0
 private void Awake()
 {
     leftHand             = this.FindComponent <ActionBasedControllerManager>("XR Origin/Camera Offset/LeftHand");
     rightHand            = this.FindComponent <ActionBasedControllerManager>("XR Origin/Camera Offset/RightHand");
     _interactionManager  = this.FindComponent <XRInteractionManager>("XR Interaction Manager");
     locomotionSystem     = this.FindGameObject("Locomotion System");
     _mainCamera          = this.FindComponent <Camera>("XR Origin/Camera Offset/Main Camera");
     leftXRRayInteractor  = LeftController.GetComponent <XRRayInteractor>();
     rightXRRayInteractor = RightController.GetComponent <XRRayInteractor>();
 }
Exemplo n.º 17
0
 private void Reset()
 {
     foreach (var controller in FindObjectsOfType <XRController>())
     {
         if (controller.controllerNode == hand && controller.TryGetComponent(out XRRayInteractor interactor))
         {
             controllerRaycast = interactor;
         }
     }
     lineDrawer = GetComponentInChildren <LineDrawer>();
 }
Exemplo n.º 18
0
    private void AddDisplay(XRController controller, XRRayInteractor interactor)
    {
        var current = Instantiate(display, controller.transform.position + controller.transform.forward * 2, controller.transform.rotation);

        SelectDisplay(current);
        if (interactor.GetCurrentRaycastHit(out var hit))
        {
            current.transform.position = hit.point + (hit.normal * 0.01f);
            current.transform.rotation = Quaternion.LookRotation(-hit.normal, Vector3.up);
        }
    }
Exemplo n.º 19
0
 private void MoveGrabbedItemBack(XRController controller, XRRayInteractor interactor)
 {
     if (IsOwner(controller) && m_target != null)
     {
         if (Vector3.Distance(interactor.attachTransform.transform.position, m_target.Transform.position) >= minZoomDistance)
         {
             m_target.Transform.rotation  = interactor.attachTransform.rotation;
             m_target.Transform.position -= m_target.Transform.forward * grabZoomSpeed * Time.deltaTime;
         }
     }
 }
Exemplo n.º 20
0
 private void TryStartGrab(XRController controller, XRRayInteractor interactor)
 {
     if (IsOwner(controller) && TryGetTarget(interactor, out m_target))
     {
         m_target.StartGrab(transform);
         if (m_style == GrabStyle.Grab)
         {
             m_target.transform.localPosition = Vector3.zero;
         }
     }
 }
Exemplo n.º 21
0
 private void Start()
 {
     teleportActivationButton = rightTeleportRay.selectUsage;
     if (rightTeleportRay)
     {
         rightRayInteractor = rightTeleportRay.gameObject.GetComponent <XRRayInteractor>();
     }
     if (leftTeleportRay)
     {
         leftRayInteractor = leftTeleportRay.gameObject.GetComponent <XRRayInteractor>();
     }
 }
Exemplo n.º 22
0
 internal static XRRayInteractor CreateRayInteractor()
 {
     GameObject interactorGO = new GameObject("Ray Interactor");
     XRController controller = interactorGO.AddComponent<XRController>();
     XRRayInteractor interactor = interactorGO.AddComponent<XRRayInteractor>();
     XRInteractorLineVisual ilv = interactorGO.AddComponent<XRInteractorLineVisual>();
     interactor.xrController = controller;
     controller.enableInputTracking = false;
     interactor.enableUIInteraction = false;
     controller.enableInputActions = false;
     return interactor;
 }
Exemplo n.º 23
0
 // Start is called before the first frame update
 void Start()
 {
     // get controllers
     if (rightTeleportRay)
     {
         rightRayInteractor = rightTeleportRay.gameObject.GetComponent <XRRayInteractor>();
     }
     if (leftTeleportRay)
     {
         leftRayInteractor = leftTeleportRay.gameObject.GetComponent <XRRayInteractor>();
     }
 }
Exemplo n.º 24
0
        internal static XRRayInteractor CreateRayInteractor()
        {
            GameObject interactorGO = new GameObject();

            interactorGO.name = "Ray Interactor";
            XRRayInteractor        interactor = interactorGO.AddComponent <XRRayInteractor>();
            XRController           controller = interactorGO.GetComponent <XRController>();
            XRInteractorLineVisual ilv        = interactorGO.AddComponent <XRInteractorLineVisual>();

            controller.enableInputTracking = false;
            return(interactor);
        }
        void Start()
        {
            m_XrController           = GetComponent <XRController>();
            m_XrRayInteractor        = GetComponent <XRRayInteractor>();
            m_XrInteractorLineVisual = GetComponent <XRInteractorLineVisual>();

            m_LinePoints = new Vector3[k_MaxLinePoints];

            m_TeleportationTarget.gameObject.SetActive(false);

            UIStateManager.stateChanged        += OnStateDataChanged;
            UIStateManager.projectStateChanged += OnProjectStateDataChanged;
        }
Exemplo n.º 26
0
 private bool TryGetTarget(XRRayInteractor interactor, out GrabTarget target)
 {
     if (interactor.GetCurrentRaycastHit(out var hit))
     {
         if (hit.transform.TryGetComponent(out Rigidbody rigidbody))
         {
             target = new GrabTarget(rigidbody, hit.transform.GetComponent <Collider>());
             return(true);
         }
     }
     target = new GrabTarget();
     return(false);
 }
Exemplo n.º 27
0
 private bool TryGetTarget(XRRayInteractor interactor, out GrabTarget target)
 {
     if (interactor.GetCurrentRaycastHit(out var hit))
     {
         if (hit.transform.TryGetComponent(out GrabTarget grabTarget))
         {
             target = grabTarget;
             return(true);
         }
     }
     target = null;
     return(false);
 }
        private void Start()
        {
            baseInteractor = GetComponent <XRBaseInteractor>();
            rayInteractor  = GetComponent <XRRayInteractor>();
            lineVisual     = GetComponent <LineVisual>();

            baseInteractor.onHoverEnter.AddListener(OnHoverEnterInteractable);
            baseInteractor.onHoverExit.AddListener(OnHoverExitInteractable);
            baseInteractor.onSelectEnter.AddListener(OnSelectEnterInteractable);
            baseInteractor.onSelectExit.AddListener(OnSelectExitInteractable);

            MatchLineLength();
        }
Exemplo n.º 29
0
 private void TryMoveTo(XRRayInteractor interactor)
 {
     if (interactor.GetCurrentRaycastHit(out var hit))
     {
         //Move to the current target position and offset from the surface based on the current normal.
         m_target.transform.position = hit.point + (hit.normal * Mathf.Max(m_target.Extents.z, 0.01f));
         //Align with the current surface.
         m_target.transform.rotation = Quaternion.FromToRotation(Vector3.forward, -hit.normal);
         return;
     }
     m_target.transform.localPosition = Vector3.forward;
     m_target.transform.rotation      = interactor.transform.rotation;
 }
Exemplo n.º 30
0
 private void SearchCalculableObject(XRRayInteractor controllerRay)
 {
     if (controllerRay.GetCurrentRaycastHit(out var hit))
     {
         //If Component that has been hit with ray has certain tag that implies that its size
         //would like to be calculated then it shows the user x, y and z as cm
         if (hit.transform.gameObject.CompareTag("Measurable"))
         {
             PrintSize(hit);
             showingText = true;
         }
     }
 }