123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- 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();
- }
- /// <summary>
- /// 初始化交互功能属性
- /// </summary>
- private void InitInteractable()
- {
- rigidbody_Interactable = this.GetComponent<Rigidbody>() == null
- ? this.gameObject.AddComponent<Rigidbody>()
- : this.GetComponent<Rigidbody>();
- childGrabAttach = this.GetComponent<VRTK_ChildOfControllerGrabAttach>() == null
- ? this.gameObject.AddComponent<VRTK_ChildOfControllerGrabAttach>()
- : this.GetComponent<VRTK_ChildOfControllerGrabAttach>();
- 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;
- }
- }
- }
|