Class ARPlacementInteractable
Controls the placement of Prefabs via a tap gesture.
Inheritance
Inherited Members
Namespace: UnityEngine.XR.Interaction.Toolkit.AR
Syntax
[AddComponentMenu("XR/AR Placement Interactable", 22)]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@2.0/api/UnityEngine.XR.Interaction.Toolkit.AR.ARPlacementInteractable.html")]
public class ARPlacementInteractable : ARBaseGestureInteractable, IXRActivateInteractable, IXRHoverInteractable, IXRSelectInteractable, IXRInteractable
Properties
fallbackLayerMask
The LayerMask that Unity uses during an additional ray cast when a user touch does not hit any AR trackable planes.
Declaration
public LayerMask fallbackLayerMask { get; set; }
Property Value
Type | Description |
---|---|
LayerMask |
objectPlaced
Gets or sets the event that is called when this Interactable places a new GameObject in the world.
Declaration
public ARObjectPlacementEvent objectPlaced { get; set; }
Property Value
Type | Description |
---|---|
ARObjectPlacementEvent |
onObjectPlaced
Gets or sets the event that is called when this Interactable places a new GameObject in the world.
Declaration
[Obsolete("onObjectPlaced has been deprecated. Use objectPlaced with updated signature instead.")]
public ARObjectPlacedEvent onObjectPlaced { get; set; }
Property Value
Type | Description |
---|---|
ARObjectPlacedEvent |
Remarks
onObjectPlaced
has been deprecated. Use objectPlaced with updated signature instead.
placementPrefab
A GameObject to place when a ray cast from a user touch hits a plane.
Declaration
public GameObject placementPrefab { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
Methods
CanStartManipulationForGesture(TapGesture)
Determines if the manipulation can start for the given gesture.
Declaration
protected override bool CanStartManipulationForGesture(TapGesture gesture)
Parameters
Type | Name | Description |
---|---|---|
TapGesture | gesture | The current gesture. |
Returns
Type | Description |
---|---|
Boolean | Returns true if the manipulation can start. Otherwise, returns false. |
Overrides
OnEndManipulation(TapGesture)
Unity calls this method automatically when the manipulation ends.
Declaration
protected override void OnEndManipulation(TapGesture gesture)
Parameters
Type | Name | Description |
---|---|---|
TapGesture | gesture | The current gesture. |
Overrides
See Also
OnObjectPlaced(ARObjectPlacementEventArgs)
Unity calls this method automatically when the user places an object.
Declaration
protected virtual void OnObjectPlaced(ARObjectPlacementEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
ARObjectPlacementEventArgs | args | Event data containing a reference to the instantiated placement object. |
PlaceObject(Pose)
Instantiates the placement object and positions it at the desired pose.
Declaration
protected virtual GameObject PlaceObject(Pose pose)
Parameters
Type | Name | Description |
---|---|---|
Pose | pose | The pose at which the placement object will be instantiated. |
Returns
Type | Description |
---|---|
GameObject | Returns the instantiated placement object at the input pose. |
See Also
TryGetPlacementPose(TapGesture, out Pose)
Gets the pose for the object to be placed from a ray cast hit triggered by a TapGesture.
Declaration
protected virtual bool TryGetPlacementPose(TapGesture gesture, out Pose pose)
Parameters
Type | Name | Description |
---|---|---|
TapGesture | gesture | The tap gesture that triggers the ray cast. |
Pose | pose | When this method returns, contains the pose of the placement object based on the ray cast hit. |
Returns
Type | Description |
---|---|
Boolean | Returns true if there is a valid ray cast hit that hit the front of a plane. Otherwise, returns false. |