protected void LoadManipulatorRenderGameObject() { AssetLoader assetLoader = AssetLoader.Instance; if (assetLoader != null) { // define the render model GameObject glovePrefab = AssetLoader.Instance.GetGameObject("GlovePrefab"); if (glovePrefab == null) { Utils.LogError("GameObject \"GlovePrefab\" was not found!"); return; } gloveGameObject = Instantiate(glovePrefab); gloveGameObject.transform.SetParent(this.transform); Vector3 gloveObjectScale = Vector3.one * ManipulatorSize; if (role == ETrackedControllerRole.RightHand) { gloveObjectScale.y *= -1f; } gloveGameObject.transform.localPosition = GLOVE_POSITION; gloveGameObject.transform.localRotation = Quaternion.Euler(GLOVE_ROTATION); gloveGameObject.transform.localScale = gloveObjectScale; Utils.SetLayer(gloveGameObject, 20); // define the colliders Transform colliderObject = gloveGameObject.transform.Find("HandDummy/Arm Bone L/Wrist Bone L/Finger Index Bone L1/Finger Index Bone L2/Finger Index Bone L3/Finger Index Bone L4"); if (colliderObject == null) { Utils.LogWarning("Manipulator is missing fingertip collider child object"); return; } fingertipCollider = colliderObject.GetComponent <SphereCollider>(); // Reduce the size of the finger tip to avoid butterfingers on the square buttons around RasterPropMonitor (the regular fingerTip's sphere clicks 3 at once). fingertipCollider.transform.localScale = _overrideFingertipScale * fingertipCollider.transform.localScale; colliderObject = gloveGameObject.transform.Find("HandDummy/Arm Bone L/Wrist Bone L"); if (colliderObject == null) { Utils.LogWarning("Manipulator is missing grip collider child object"); return; } gripCollider = colliderObject.GetComponent <CapsuleCollider>(); // retrieve the animator manipulatorAnimator = gloveGameObject.GetComponent <Animator>(); FingertipManipulator fingertipManipulator = fingertipCollider.gameObject.AddComponent <FingertipManipulator>(); FingertipCollidedGameObjects = fingertipManipulator.CollidedGameObjects; } }
protected void CreateGloveGameObject() { // get the prefab glovePrefab = AssetLoader.Instance.GetGameObject("GlovePrefab"); if (glovePrefab == null) { Utils.LogError("GameObject \"GlovePrefab\" was not found!"); return; } gloveGameObject = Instantiate(glovePrefab); gloveGameObject.transform.SetParent(this.transform); Vector3 gloveObjectScale = Vector3.one * ManipulatorSize; if (Role == ETrackedControllerRole.RightHand) { gloveObjectScale.y *= -1f; } gloveGameObject.transform.localPosition = GLOVE_POSITION; gloveGameObject.transform.localRotation = Quaternion.Euler(GLOVE_ROTATION); gloveGameObject.transform.localScale = gloveObjectScale; Utils.SetLayer(gloveGameObject, KerbalVR.Scene.Instance.RenderLayer); // define the colliders Transform colliderObject = gloveGameObject.transform.Find("HandDummy/Arm Bone L/Wrist Bone L/Finger Index Bone L1/Finger Index Bone L2/Finger Index Bone L3/Finger Index Bone L4"); if (colliderObject == null) { Utils.LogWarning("Manipulator is missing fingertip collider child object"); return; } FingertipCollider = colliderObject.GetComponent <SphereCollider>(); colliderObject = gloveGameObject.transform.Find("HandDummy/Arm Bone L/Wrist Bone L"); if (colliderObject == null) { Utils.LogWarning("Manipulator is missing grip collider child object"); return; } GripCollider = colliderObject.GetComponent <CapsuleCollider>(); // retrieve the animator manipulatorAnimator = gloveGameObject.GetComponent <Animator>(); FingertipManipulator fingertipManipulator = FingertipCollider.gameObject.AddComponent <FingertipManipulator>(); FingertipCollidedGameObjects = fingertipManipulator.CollidedGameObjects; }
protected void Start() { FingertipManipulator fingertipManipulator = fingertipCollider.gameObject.AddComponent <FingertipManipulator>(); FingertipCollidedGameObjects = fingertipManipulator.CollidedGameObjects; }