UxrGrabbableObjectAnchor Class
Component that, added to a GameObject, will enable UxrGrabbableObject objects to be placed on it. Some of the main features of grabbable object anchors are:
- Placement mechanics are handled automatically by the UxrGrabManager. There is no special requirement to set it up in a scene, the grab manager will be available as soon as it is required.
- Compatible tags allow to model which objects can be placed on the anchor. If the list is empty, the anchor is compatible with all other UxrGrabbableObject that do not have a tag.
- Events such as Placed and Removed allow to write logic when a user interacts with the anchor. Each one has pre and post events.
- ActivateOnCompatibleNear, ActivateOnCompatibleNotNear, ActivateOnHandNearAndGrabbable, ActivateOnPlaced and ActivateOnEmpty can be used to activate/deactivate objects on manipulation events. They can be assigned during edit-time using the inspector and also at runtime.
- AddPlacingValidator(Func(UxrGrabbableObject, Boolean)) and RemovePlacingValidator(Func(UxrGrabbableObject, Boolean)) can be used to model complex compatibility behaviour that changes at runtime.
Inheritance Hierarchy
System.Object
Object
Component
Behaviour
MonoBehaviour
UltimateXR.Core.Components.UxrComponent
UltimateXR.Core.Components.UxrComponent(UxrGrabbableObjectAnchor)
UltimateXR.Manipulation.UxrGrabbableObjectAnchor
Namespace: UltimateXR.Manipulation
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0
Syntax
C#
public class UxrGrabbableObjectAnchor : UxrComponent<UxrGrabbableObjectAnchor>
The UxrGrabbableObjectAnchor type exposes the following members.
Constructors
Name | Description | |
---|---|---|
UxrGrabbableObjectAnchor |
Properties
Name | Description | |
---|---|---|
ActivateOnCompatibleNear | Gets or sets the object that will be enabled or disabled depending on if there is a grabbed compatible UxrGrabbableObject close enough to be placed on it. | |
ActivateOnCompatibleNotNear | Gets or sets the object that will be enabled or disabled depending on if there isn’t a grabbed compatible UxrGrabbableObject close enough to be placed on it. | |
ActivateOnEmpty | Gets or sets the object that will be enabled or disabled depending on if there isn’t a UxrGrabbableObject currently placed on the anchor. | |
ActivateOnHandNearAndGrabbable | Gets or sets the object that will be enabled or disabled depending on if there is a UxrGrabbableObject currently placed on the anchor and a UxrGrabber close enough to grab it. | |
ActivateOnPlaced | Gets or sets the object that will be enabled or disabled depending on if there is a UxrGrabbableObject currently placed on the anchor. | |
AlignTransform | Gets the Transform that will be used to snap the UxrGrabbableObject placed on it. | |
CurrentPlacedObject | Gets the UxrGrabbableObject that is currently placed on the anchor. | |
DropProximityTransform | Gets the Transform that will be used to compute the distance to UxrGrabbableObject that can be placed on it, in order to determine if they are close enough. | |
MaxPlaceDistance | Gets or sets the maximum distance from which an object that is released will be placed on the anchor. |
Methods
Name | Description | |
---|---|---|
AddCompatibleTags | Adds compatible tags to the list of compatible tags that control which objects can be placed on the anchor. | |
AddPlacingValidator | Adds a placing validator to the internal list of validators. Placing validators are functions that are used in addition to compatibility tags in order to determine if a UxrGrabbableObject can be placed on the anchor. An object can be placed on an anchor if the tag is compatible and if it is allowed by all of the placing validators. | |
Awake | Initializes the component. (Overrides UxrComponent<T>.Awake().) | |
IsCompatibleObject | Checks whether the given UxrGrabbableObject is compatible with the anchor, which means that it can potentially be placed on it if there is no other object placed. | |
OnDestroy | Removes the validators. (Overrides UxrComponent<T>.OnDestroy().) | |
RemoveCompatibleTags | Removes compatible tags from the list of compatible tags that control which objects can be placed on the anchor. | |
RemoveObject | Removes the currently placed object, if there is any, from the anchor. | |
RemovePlacingValidator | Removes a placing validator added using AddPlacingValidator(Func(UxrGrabbableObject, Boolean)). | |
Start | Performs additional initialization. (Overrides UxrComponent.Start().) |
Events
Name | Description | |
---|---|---|
Placed | Event called right after an object was placed on the anchor. | |
Placing | Event called right before an object is placed on the anchor. | |
Removed | Event called right after the currently placed object is removed from the anchor. | |
Removing | Event called right before the currently placed object is removed from the anchor. | |
SmoothPlaceTransitionEnded | Event called right after an object that was placed on the anchor ended its smooth placing transition. |
Extension Methods
Name | Description | |
---|---|---|
CheckSetEnabled | Enables/disabled the component if it isn’t enabled already. (Defined by MonoBehaviourExt.) | |
GetOrAddComponent<T> | Gets the Component of a given type. If it doesn’t exist, it is added to the GameObject. (Defined by ComponentExt.) | |
GetPathUnderScene | Gets the full path under current scene, including all parents, but scene name, for the given component. (Defined by ComponentExt.) | |
GetSceneUid | Gets an unique identifier string for the given component. (Defined by ComponentExt.) | |
GetUniqueScenePath | Gets an unique path in the scene for the given component. It will include scene name, sibling and component indices to make it unique. (Defined by ComponentExt.) | |
LoopCoroutine | Creates a coroutine that simplifies executing a loop during a certain amount of time. (Defined by MonoBehaviourExt.) | |
SafeGetComponentInParent<T> | Gets the Component of a given type in the GameObject or any of its parents. It also works on prefabs, where regular GetComponentInParent(Type, Boolean) will not work: https://issuetracker.unity3d.com/issues/getcomponentinparent-is-returning-null-when-the-gameobject-is-a-prefab (Defined by ComponentExt.) | |
ShowInInspector(Boolean) | Overloaded. Controls whether to show the current object in the inspector. (Defined by ObjectExt.) | |
ShowInInspector(Boolean, Boolean) | Overloaded. Controls whether to show the current object in the inspector and whether it is editable. (Defined by ObjectExt.) | |
ThrowIfNull | Throws an exception if the object is null. (Defined by ObjectExt.) |