// Update is called once per frame
    //check to see teleportation is activated
    void Update()
    {
        //see if the line/etc should be active/if the button is pushed
        bool isTeleportActive = CheckIfActivated(controller);

        //set line and raycaster active or inactive depending on whether the button is pushed
        XRRayInteractor        teleportRay          = controller.GetComponent <XRRayInteractor>();
        LineRenderer           teleportLineRenderer = controller.GetComponent <LineRenderer>();
        XRInteractorLineVisual teleportLineVisual   = controller.GetComponent <XRInteractorLineVisual>();

        teleportRay.enabled          = isTeleportActive;
        teleportLineRenderer.enabled = isTeleportActive;
        teleportLineVisual.enabled   = isTeleportActive;
        reticle.SetActive(isTeleportActive);
    }
Exemple #2
0
 public MockHMDInput(XRController right, XRController left)
 {
     m_rightController = right;
     m_leftController  = left;
     m_rightHand       = right.GetComponent <XRRayInteractor>();
     m_leftHand        = left.GetComponent <XRRayInteractor>();
 }
Exemple #3
0
    private void OnGrabHold(XRController controller)
    {
        switch (grab)
        {
        case GrabState.None:
            grab = GrabState.One;
            var hover = controller.GetComponent <OnHoverEventHandler>();
            if (hover.Current != null)
            {
                grabbedObject = hover.Current;
            }
            else
            {
                if (MultiGrab)
                {
                    grabbedObject = LayerManager.Instance.LayerHelper;
                    foreach (Layer layer in LayerManager.Instance.layers)
                    {
                        layer.transform.parent = LayerManager.Instance.LayerHelper.transform;
                    }
                }
                else
                {
                    grabbedObject = LayerManager.Instance.ActiveLayer.gameObject;
                }
                before = new TransformObject(grabbedObject.transform);
            }

            originalParent = grabbedObject.transform.parent;

            movable   = grabbedObject.GetComponent <IMovable>();
            resizable = grabbedObject.GetComponent <IResizable>();

            if (movable != null)
            {
                grabbedObject.transform.parent = controller.transform;
            }
            break;

        case GrabState.One:
            grab = GrabState.Both;

            var pos = grabbedObject.transform.position;
            grabbedObject.transform.parent   = originalParent;
            grabbedObject.transform.position = pos;

            refDist        = Vector3.Distance(leftController.transform.position, rightController.transform.position);
            refPos         = grabbedObject.transform.position;
            refCenter      = center;
            refScale       = grabbedObject.transform.localScale;
            refRot         = grabbedObject.transform.rotation;
            refControllers = (rightController.transform.position - leftController.transform.position).normalized;
            refUp          = (leftController.transform.up + rightController.transform.up).normalized;
            ToolController.Instance.ToggleSelectedTool(false);
            break;

        default:
            break;
        }
    }
Exemple #4
0
    void Awake()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        _instance = this;

        OnHoverEventHandler leftHover  = leftController.GetComponent <OnHoverEventHandler>();
        OnHoverEventHandler rightHover = rightController.GetComponent <OnHoverEventHandler>();

        LeftGripHandler.OnValueChange += (controller, value) =>
        {
            if (value != leftVal)
            {
                if (value > 0.5f != leftVal > 0.5f)
                {
                    if (value > 0.5f)
                    {
                        OnGrabHold(controller);
                    }
                    else
                    {
                        OnGrabRelease(controller);
                    }
                }
                leftVal = value;
            }
        };

        RightGripHandler.OnValueChange += (controller, value) =>
        {
            if (value != rightVal)
            {
                if (value > 0.5f != rightVal > 0.5f)
                {
                    if (value > 0.5f)
                    {
                        OnGrabHold(controller);
                    }
                    else
                    {
                        OnGrabRelease(controller);
                    }
                }
                rightVal = value;
            }
        };
        source = GetComponent <AudioSource>();

        multiGrabButton.OnButtonDown += (c) =>
        {
            if (grab == GrabState.None)
            {
                MultiGrab = !MultiGrab;
            }
            if (MultiGrab)
            {
                source.PlayOneShot(multiGrabClip);
            }
            else
            {
                source.PlayOneShot(singleGrabClip);
            }
        };
    }
Exemple #5
0
 public XRControllerAction(XRController controller)
 {
     m_triggerStates = new Dictionary <InputHelpers.Button, FakeState>();
     Controller      = controller;
     Ray             = controller.GetComponent <XRRayInteractor>();
 }