namespace ChivaXR.VR { using System.Collections; using System.Collections.Generic; using UnityEngine; using VRTK.GrabAttachMechanics; public class CVR_InteractableVRTK_ChildOfController : CVR_InteractableVRTK { private VRTK_ChildOfControllerGrabAttach childGrabAttach; private Rigidbody rigidbody_Interactable; protected override void Awake() { InitInteractable(); base.Awake(); } /// /// 初始化交互功能属性 /// private void InitInteractable() { rigidbody_Interactable = this.GetComponent() == null ? this.gameObject.AddComponent() : this.GetComponent(); childGrabAttach = this.GetComponent() == null ? this.gameObject.AddComponent() : this.GetComponent(); this.isUsable = true; this.useOnlyIfGrabbed = true; this.isGrabbable = true; this.holdButtonToGrab = false; this.holdButtonToUse = true; if (this.grabAttachMechanicScript == null) { this.grabAttachMechanicScript = childGrabAttach; childGrabAttach.precisionGrab = true; } rigidbody_Interactable.isKinematic = true; rigidbody_Interactable.useGravity = false; } } }