protected virtual void OnEnable() { scriptControllerAlias = (controllerAlias != null ? controllerAlias : gameObject); actualController = VRTK_DeviceFinder.GetActualController(scriptControllerAlias); if (actualController != null) { trackedController = actualController.GetComponent <VRTK_TrackedController>(); if (trackedController != null) { trackedController.ControllerModelAvailable += DoControllerModelAvailable; } if (trackedControllerReady) { ControllerAvailable(); } } else { VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_ControllerHighlighter", "Controller Alias GameObject", "controllerAlias", "the same")); } }
private Transform GetTransform(Transform setTransform, VRTK_ControllerElements findElement) { Transform returnTransform = null; if (setTransform) { returnTransform = setTransform; } else { var actualController = VRTK_DeviceFinder.GetActualController(controllerActions.gameObject); if (actualController && actualController.activeInHierarchy) { var controllerHand = VRTK_DeviceFinder.GetControllerHand(controllerActions.gameObject); var elementPath = VRTK_SDK_Bridge.GetControllerElementPath(findElement, controllerHand, true); returnTransform = actualController.transform.FindChild(elementPath); } } return(returnTransform); }
private void SetControllerAttachPoint() { var actualController = VRTK_DeviceFinder.GetActualController(gameObject); //If no attach point has been specified then just use the tip of the controller if (actualController && controllerAttachPoint == null) { //attempt to find the attach point on the controller var defaultAttachPoint = actualController.transform.Find(VRTK_SDK_Bridge.GetControllerElementPath(VRTK_ControllerElements.AttachPoint, VRTK_DeviceFinder.GetControllerHand(gameObject))); if (defaultAttachPoint != null) { controllerAttachPoint = defaultAttachPoint.GetComponent <Rigidbody>(); if (controllerAttachPoint == null) { var autoGenRB = defaultAttachPoint.gameObject.AddComponent <Rigidbody>(); autoGenRB.isKinematic = true; controllerAttachPoint = autoGenRB; } } } }
private void OnEnable() { modelContainer = (!modelContainer ? VRTK_DeviceFinder.GetActualController(gameObject) : modelContainer); StartCoroutine(WaitForModel()); }