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;
        }
예제 #2
0
        private void Start()
        {
            baseInteractor     = GetComponent <XRBaseInteractor>();
            teleportLineVisual = GetComponent <XRInteractorLineVisual>();
            lineRenderer       = GetComponent <LineRenderer>();

            teleportLineVisual.enabled = false;
            baseInteractor.enabled     = false;
        }
예제 #3
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);
        }
        /// <summary>
        /// When passed a gameObject, this function will scrape the game object for all valid components that we will
        /// interact with by enabling/disabling as the state changes
        /// </summary>
        /// <param name="gameObject">The game object to scrape the various components from</param>
        public void Attach(GameObject gameObject)
        {
            m_GO = gameObject;
            if (m_GO != null)
            {
                m_XRController = m_GO.GetComponent <XRController>();
                m_LineRenderer = m_GO.GetComponent <XRInteractorLineVisual>();
                m_Interactor   = m_GO.GetComponent <XRBaseInteractor>();

                Leave();
            }
        }
예제 #5
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;
 }
        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;
        }
예제 #7
0
            /// <summary>
            /// When passed a gameObject, this function will scrape the game object for all valid components that we will
            /// interact with by enabling/disabling as the state changes
            /// </summary>
            /// <param name="gameObject">The game object to scrape the various components from</param>
            public void Attach(GameObject gameObject)
            {
                target = gameObject;

                if (target != null)
                {
                    controller   = target.GetComponent <XRController>();
                    lineRenderer = target.GetComponent <XRInteractorLineVisual>();
                    interactor   = target.GetComponent <XRBaseInteractor>();

                    Leave();
                }
            }
예제 #8
0
    void Start()
    {
        m_RightLineVisual         = RightTeleportInteractor.GetComponent <XRInteractorLineVisual>();
        m_RightLineVisual.enabled = false;

        m_LeftLineVisual         = LeftTeleportInteractor.GetComponent <XRInteractorLineVisual>();
        m_LeftLineVisual.enabled = false;

        m_RightController = RightTeleportInteractor.GetComponent <XRReleaseController>();
        m_LeftController  = LeftTeleportInteractor.GetComponent <XRReleaseController>();

        m_OriginalRightMask = RightTeleportInteractor.interactionLayerMask;
        m_OriginalLeftMask  = LeftTeleportInteractor.interactionLayerMask;

        if (!DisableSetupForDebug)
        {
            transform.position = StartingPosition.position;
            transform.rotation = StartingPosition.rotation;

            if (TeleporterParent != null)
            {
                TeleporterParent.SetActive(false);
            }
        }

        InputDeviceCharacteristics leftTrackedControllerFilter = InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.Left;
        List <InputDevice>         foundControllers            = new List <InputDevice>();

        InputDevices.GetDevicesWithCharacteristics(leftTrackedControllerFilter, foundControllers);

        if (foundControllers.Count > 0)
        {
            m_LeftInputDevice = foundControllers[0];
        }


        InputDeviceCharacteristics rightTrackedControllerFilter = InputDeviceCharacteristics.HeldInHand | InputDeviceCharacteristics.Right;

        InputDevices.GetDevicesWithCharacteristics(rightTrackedControllerFilter, foundControllers);

        if (foundControllers.Count > 0)
        {
            m_RightInputDevice = foundControllers[0];
        }

        if (m_Rig.TrackingOriginMode != TrackingOriginModeFlags.Floor)
        {
            m_Rig.cameraYOffset = 1.8f;
        }
    }
    // 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);
    }
예제 #10
0
    // Start is called before the first frame update
    void Awake()
    {
        _rightray        = rightControllerObj.GetComponent <XRInteractorLineVisual>();
        _rightController = rightControllerObj.GetComponent <XRController>();
        _rightLine       = rightControllerObj.GetComponent <LineRenderer>();

        _leftray        = leftControllerObj.GetComponent <XRInteractorLineVisual>();
        _leftController = leftControllerObj.GetComponent <XRController>();
        _leftLine       = leftControllerObj.GetComponent <LineRenderer>();

        originalLineWidth = _rightLine.startWidth;

        XRRig_Script = player.GetComponent <XRRig>();

        lineLength = _rightray.lineLength;

        currentReticleScale = reticlePrefab.transform.localScale = new Vector3(1, .05f, 1);
        _rightray.reticle   = _leftray.reticle = reticlePrefab;
    }
        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);

            UIStateManager.stateChanged        += OnStateDataChanged;
            UIStateManager.projectStateChanged += OnProjectStateDataChanged;

            m_TeleportAction = m_InputActionAsset["VR/Teleport"];
            m_InputActionAsset["VR/Select"].performed += OnTeleport;
            m_MainCamera = Camera.main.transform;
        }
예제 #12
0
        private void Awake()
        {
            levelChanger = FindObjectOfType <LevelChanger> ();  // Set reference to level changer
            levelChanger.GetComponent <Animator> ().speed = 1f; // Make sure on start that the level changer animation speed is normal

            currentSceneName = SceneManager.GetActiveScene().name;

            rayInteractor = FindObjectOfType <XRRayInteractor> ();
            lineRenderer  = FindObjectOfType <LineRenderer> ();
            lineVisual    = FindObjectOfType <XRInteractorLineVisual> ();

            if (currentSceneName == "MainMenu")
            {
                rayInteractor.enabled = lineRenderer.enabled = lineVisual.enabled = true; // Activate line interactions
                menuControl           = FindObjectOfType <MenuControl> ();
            }
            else
            {
                rayInteractor.enabled = lineRenderer.enabled = lineVisual.enabled = false; // Deactivate point interactions
            }
        }
예제 #13
0
 ///////////////////
 //private methods
 ///////////////////
 private void Awake()
 {
     _xrray      = GetComponent <XRRayInteractor>();
     _linerender = GetComponent <LineRenderer>();
     _xrLineVis  = GetComponent <XRInteractorLineVisual>();
 }
예제 #14
0
        public ControllerWithRayInteractor(
            XRInteractionManager interactionManager,
            XRNode node,
            string gameObjectName,
            bool constructScene)
            : base(node: node, gameObjectName: gameObjectName, constructScene: constructScene)
        {
            if (constructScene)
            {
                LineRenderer = GameObject.AddComponent <LineRenderer>();

                LineRenderer.numCornerVertices = 4;

                LineRenderer.numCapVertices = 4;

                string lineMaterialResourcePath = "GemPlay/Materials/XRRaycast";

                var material = Resources.Load(lineMaterialResourcePath) as Material;

                if (material == null)
                {
                    Debug.LogError("Found nothing at " + lineMaterialResourcePath);
                }

                LineRenderer.material = material;

                LineRenderer.sortingOrder = 5;


                XRRayInteractor = GameObject.AddComponent <XRRayInteractor>();


                XRInteractorLineVisual = GameObject.AddComponent <XRInteractorLineVisual>();

                XRInteractorLineVisual.lineWidth = 0.005f;

                XRInteractorLineVisual.lineLength = 2.0f;

                var invalidGradientColorKey = new GradientColorKey[2];

                invalidGradientColorKey[0].color = Color.white;

                invalidGradientColorKey[1].color = Color.white;

                var alphaKey = new GradientAlphaKey[2];

                alphaKey[0].alpha = 1.0f;

                alphaKey[0].time = 0.0f;

                alphaKey[1].alpha = 0.0f;

                alphaKey[1].time = 1.0f;

                XRInteractorLineVisual.invalidColorGradient.SetKeys(invalidGradientColorKey, alphaKey);

                var validGradientColorKey = new GradientColorKey[2];

                validGradientColorKey[0].color = Color.green;

                validGradientColorKey[1].color = Color.green;

                var validGradient = new Gradient();

                validGradient.SetKeys(validGradientColorKey, alphaKey);

                XRInteractorLineVisual.validColorGradient.SetKeys(validGradientColorKey, alphaKey);
            }
            else
            {
                LineRenderer = GameObject.GetComponent <LineRenderer>();

                XRRayInteractor = GameObject.GetComponent <XRRayInteractor>();

                XRInteractorLineVisual = GameObject.GetComponent <XRInteractorLineVisual>();
            }

            XRRayInteractor.interactionManager = interactionManager;
        }
예제 #15
0
 private void Awake()
 {
     xRInteractorLineVisual = GetComponent <XRInteractorLineVisual>();
     material = GetComponent <LineRenderer>().materials[0];
     GradientCheck(false);
 }
 private void Awake()
 {
     lineRenderer = GetComponent <XRInteractorLineVisual>();
 }
예제 #17
0
 void Awake()
 {
     xrLineVisual = this.GetComponent <XRInteractorLineVisual>();
     Debug.Log("XRLineVisualBehavior Awake");
 }