XR-RokidAR-UXR3.0-Throwable 脚本解析

using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;

namespace Rokid.UXR.Interaction
{
    public enum ReleaseStyle
    {
        NoChange,
        GetFromHand,
        ShortEstimation
    }
    [RequireComponent(typeof(GrabInteractable))]
    [RequireComponent(typeof(Rigidbody))]
    public class Throwable : MonoBehaviour, IHandHoverBegin, IHandHoverUpdate, IHandHoverEnd, IGrabbedToHand, IReleasedFromHand, IGrabbedUpdate
    {
        [Tooltip("The flags used to attach this object to the hand.")]
        public GrabFlags grabbedFlags = GrabFlags.ParentToHand | GrabFlags.ReleaseFromOtherHand | GrabFlags.TurnOnKinematic;

        [Tooltip("The local point which acts as a positional and rotational offset to use while held")]
        public Transform grabbedOffset;

        [Tooltip("How fast must this object be moving to attach due to a trigger hold instead of a trigger press? (-1 to disable)")]
        public float catchingSpeedThreshold = -1;
        public ReleaseStyle releaseVelocityStyle = ReleaseStyle.GetFromHand;

        [Tooltip("The time offset used when releasing the object with the RawFromHand option")]
        public float releaseVelocityTimeOffset = -0.011f;
        public float scaleReleaseVelocity = 1.1f;
        public float scaleReleaseAngularVelocity = 1.0f;

        [Tooltip("The release velocity magnitude representing the end of the scale release velocity curve. (-1 to disable)")]
        public float scaleReleaseVelocityThreshold = -1.0f;
        [Tooltip("Use this curve to ease into the scaled release velocity based on the magnitude of the measured release velocity. This allows greater differentiation between a drop, toss, and throw.")]
        public AnimationCurve scaleReleaseVelocityCurve = AnimationCurve.EaseInOut(0.0f, 0.1f, 1.0f, 1.0f);

        [Tooltip("When detaching the object, should it return to its original parent?")]
        public bool restoreOriginalParent = false;
        protected VelocityEstimator velocityEstimator;
        protected bool grabbed = false;
        protected float grabTime;
        protected Vector3 grabPosition;
        protected Quaternion grabRotation;
        protected Transform attachEaseInTransform;
        //刚体插值类型
        protected RigidbodyInterpolation hadInterpolation = RigidbodyInterpolation.None;
        protected new Rigidbody rigidbody;
        public UnityEvent OnPickUp = new UnityEvent();
        public UnityEvent OnDropDown = new UnityEvent();
        public UnityEvent OnHeldUpdate = new UnityEvent();

        [HideInInspector]
        public GrabInteractable interactable;

        private void Start()
        {
            velocityEstimator = GetComponent();
            interactabl

你可能感兴趣的:(XR,xr,unity,android,游戏引擎)