// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) VRMADA, All rights reserved. // // -------------------------------------------------------------------------------------------------------------------- using System; using UnityEngine; namespace UltimateXR.Manipulation { /// /// Interface for all objects that can be grabbed/manipulated using the . /// public interface IUxrGrabbable { #region Public Types & Data /// /// Event called when the object is about to be grabbed. /// The following properties from will contain meaningful data: /// /// /// : Object that is about to be grabbed. /// /// /// : Target where the object is currently placed. Null /// if it isn't on an anchor. /// /// /// : Grabber that is about to grab the object. /// /// /// : Grab point index of the object that is about to be /// grabbed. /// /// /// : true if it is already being grabbed with one hand and /// it will be grabbed with both hands after. False if no hand is currently grabbing it. /// /// /// public event EventHandler Grabbing; /// /// Event called right after the object was grabbed. The grab event parameters use the same values as /// . /// public event EventHandler Grabbed; /// /// Event called when the object is about to be released. An object is released when the last grip is released and /// there is no compatible near enough to place it on. /// The following properties from will contain meaningful data: /// /// /// : Object that is about to be released. /// /// /// : Anchor where the object was originally grabbed /// from. Null if it wasn't on a target. /// /// /// : Grabber that is about to release the object. /// /// /// : Grab point index of the object that is being /// grabbed by the . /// /// /// : true if it is already being grabbed with another hand /// that will keep it holding. False if no other hand is currently grabbing it. /// /// /// : True if it was released because another /// grabbed it, false otherwise. if /// is /// true then will tell if it was released by both hands /// (false) or if it was just released by one hand and the other one still keeps it grabbed (true). /// /// /// : Velocity the object is being released with. /// /// /// : Angular velocity the object is being /// released with. /// /// /// public event EventHandler Releasing; /// /// Event called right after the object was released. An object is released when the last grip is released and there is /// no compatible near enough to place it on. /// The grab event parameters use the same values as . /// public event EventHandler Released; /// /// Event called when the object is about to be placed. An object is placed when the last grip is released and there is /// a compatible near enough to place it on. /// The following properties from will contain meaningful data: /// /// /// : Object that is about to be removed. /// /// /// : Anchor where the object is currently placed. /// /// /// : Grabber that is about to remove the object by grabbing it. /// This can be null if the object is removed through code using /// , /// or > /// /// /// : Only if the object is being removed by grabbing it: /// Grab point index of the object that is about to be grabbed by the . /// /// /// public event EventHandler Placing; /// /// Event called right after the object was placed. An object is placed when the last grip is released and there is a /// compatible near enough to place it on. /// The grab event parameters use the same values as . /// public event EventHandler Placed; /// /// Gets the associated . Since all components that implement the interface will be assigned /// to GameObjects, this allows to access them using the interface. /// It doesn't follow the property PascalCase naming to make it compatible with Unity. /// public GameObject gameObject { get; } /// /// Gets the associated component. Since all components that implement the interface will be /// assigned to GameObjects, this allows to access their transform using the interface. /// It doesn't follow the property PascalCase naming to make it compatible with Unity. /// public Transform transform { get; } /// /// Gets whether the object is being grabbed. /// public bool IsBeingGrabbed { get; } /// /// Gets or sets whether the object can be grabbed. /// public bool IsGrabbable { get; set; } /// /// Gets or sets whether the rigidbody that drives the object (if any) is kinematic. /// public bool IsKinematic { get; set; } #endregion #region Public Methods /// /// Resets the object to its initial position/rotation and state. If the object is currently being grabbed, it will be /// released. /// /// Should events be generated? public void ResetPositionAndState(bool propagateEvents); /// /// Releases the object from all its grabs if there are any. /// /// Should events be generated? public void ReleaseGrabs(bool propagateEvents); #endregion } }