Example #1
0
        protected virtual void Start()
        {
            if (controller == null)
            {
                controller = this.GetComponent <VRTK_ControllerEvents>();
            }

            if (controller == null)
            {
                Debug.LogError("VRTK_WorldPointer requires a SteamVR Controller that has the VRTK_ControllerEvents script attached to it");
                return;
            }

            Utilities.SetPlayerObject(this.gameObject, VRTK_PlayerObject.ObjectTypes.Controller);

            //Setup controller event listeners
            controller.AliasPointerOn  += new ControllerInteractionEventHandler(EnablePointerBeam);
            controller.AliasPointerOff += new ControllerInteractionEventHandler(DisablePointerBeam);
            eventsRegistered            = true;

            headset = DeviceFinder.HeadsetTransform();

            playArea = GameObject.FindObjectOfType <SteamVR_PlayArea>();
            playAreaCursorBoundaries = new GameObject[4];

            var tmpMaterial = Resources.Load("WorldPointer") as Material;

            if (pointerMaterial != null)
            {
                tmpMaterial = pointerMaterial;
            }

            pointerMaterial       = new Material(tmpMaterial);
            pointerMaterial.color = pointerMissColor;
        }
        private void Start()
        {
            this.name           = "PlayerObject_" + this.name;
            lastGoodPositionSet = false;
            headset             = DeviceFinder.HeadsetTransform();
            CreateCollider();
            InitHeadsetListeners();

            var controllerManager = GameObject.FindObjectOfType <SteamVR_ControllerManager>();

            InitControllerListeners(controllerManager.left);
            InitControllerListeners(controllerManager.right);
        }
Example #3
0
        private void Start()
        {
            Utilities.SetPlayerObject(this.gameObject, VRTK_PlayerObject.ObjectTypes.CameraRig);

            lastGoodPositionSet = false;
            headset             = DeviceFinder.HeadsetTransform();
            CreateCollider();
            InitHeadsetListeners();

            var controllerManager = GameObject.FindObjectOfType <SteamVR_ControllerManager>();

            InitControllerListeners(controllerManager.left);
            InitControllerListeners(controllerManager.right);
        }
Example #4
0
        protected virtual void Awake()
        {
            if (controller == null)
            {
                controller = GetComponent <VRTK_ControllerEvents>();
            }

            if (controller == null)
            {
                Debug.LogError("VRTK_WorldPointer requires a SteamVR Controller that has the VRTK_ControllerEvents script attached to it");
                return;
            }

            Utilities.SetPlayerObject(gameObject, VRTK_PlayerObject.ObjectTypes.Controller);

            headset  = DeviceFinder.HeadsetTransform();
            playArea = FindObjectOfType <SteamVR_PlayArea>();
            playAreaCursorBoundaries = new GameObject[4];
        }
Example #5
0
        protected virtual void Start()
        {
            if (GetComponent <VRTK_ControllerEvents>() == null)
            {
                Debug.LogError("VRTK_WorldPointer is required to be attached to a SteamVR Controller that has the VRTK_ControllerEvents script attached to it");
                return;
            }

            this.name = "PlayerObject_" + this.name;

            //Setup controller event listeners
            GetComponent <VRTK_ControllerEvents>().AliasPointerOn  += new ControllerInteractionEventHandler(EnablePointerBeam);
            GetComponent <VRTK_ControllerEvents>().AliasPointerOff += new ControllerInteractionEventHandler(DisablePointerBeam);

            headset = DeviceFinder.HeadsetTransform();

            playArea = GameObject.FindObjectOfType <SteamVR_PlayArea>();
            playAreaCursorBoundaries = new GameObject[4];

            pointerMaterial       = new Material(Shader.Find("Unlit/TransparentColor"));
            pointerMaterial.color = pointerMissColor;
        }
Example #6
0
        protected virtual void Start()
        {
            /*
             * if (GetComponent<VRTK_ControllerEvents>() == null)
             * {
             *  Debug.LogError("VRTK_WorldPointer is required to be attached to a SteamVR Controller that has the VRTK_ControllerEvents script attached to it");
             *  return;
             * }
             */

            this.name = "PlayerObject_" + this.name;

            /*
             * //Setup controller event listeners
             * GetComponent<VRTK_ControllerEvents>().AliasPointerOn += new ControllerInteractionEventHandler(EnablePointerBeam);
             * GetComponent<VRTK_ControllerEvents>().AliasPointerOff += new ControllerInteractionEventHandler(DisablePointerBeam);
             */

            headset = DeviceFinder.HeadsetTransform();

            playArea = GameObject.FindObjectOfType <SteamVR_PlayArea>();
            playAreaCursorBoundaries = new GameObject[4];

            //pointerMaterial = new Material(Shader.Find("Unlit/TransparentColor"));
            pointerMaterial = new Material(Shader.Find("Valve/vr_standard"));
            //pointerMaterial.color = pointerMissColor;

            pointerMaterial.DisableKeyword("_ALPHATEST_ON");
            pointerMaterial.EnableKeyword("_ALPHABLEND_ON");
            pointerMaterial.DisableKeyword("_ALPHAPREMULTIPLY_ON");

            pointerMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
            pointerMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
            pointerMaterial.SetInt("_ZWrite", 0);
            pointerMaterial.renderQueue = 3000;

            pointerMaterial.SetFloat("_Mode", 3f);
            pointerMaterial.SetColor("_Color", pointerMissColor);
        }