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; }
public static Transform AddCameraFade() { var camera = DeviceFinder.HeadsetCamera(); if (camera && !camera.gameObject.GetComponent <SteamVR_Fade>()) { camera.gameObject.AddComponent <SteamVR_Fade>(); } return(camera); }
public bool IsValidInteractableController(GameObject actualController, AllowedController controllerCheck) { if (controllerCheck == AllowedController.Both) { return(true); } var controllerHand = DeviceFinder.GetControllerHandType(controllerCheck.ToString().Replace("_Only", "")); return(DeviceFinder.IsControllerOfHand(actualController, controllerHand)); }
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); }
public virtual void ToggleBeam(bool state) { var index = DeviceFinder.GetControllerIndex(gameObject); if (state) { TurnOnBeam(index); } else { TurnOffBeam(index); } }
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); }
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]; }
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; }
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); }
private Transform GetSnapHandle(VRTK_InteractableObject objectScript) { if (objectScript.rightSnapHandle == null && objectScript.leftSnapHandle != null) { objectScript.rightSnapHandle = objectScript.leftSnapHandle; } if (objectScript.leftSnapHandle == null && objectScript.rightSnapHandle != null) { objectScript.leftSnapHandle = objectScript.rightSnapHandle; } if (DeviceFinder.IsControllerOfHand(this.gameObject, DeviceFinder.ControllerHand.Right)) { return(objectScript.rightSnapHandle); } if (DeviceFinder.IsControllerOfHand(this.gameObject, DeviceFinder.ControllerHand.Left)) { return(objectScript.leftSnapHandle); } return(null); }