Class TapToPlace
Tap to place is a far interaction component used to place objects on a surface.
Implements
MonoBehaviour
IMixedRealityPointerHandler
Assembly: cs.temp.dll.dll
public class TapToPlace : Solver, MonoBehaviour, IMixedRealityPointerHandler
Fields
Declaration
protected RaycastHit CurrentHit
Field Value
Type |
Description |
RaycastHit |
|
The current ray is based on the TrackedTargetType (Controller Ray, Head, Hand Joint).
The following properties are updated each frame while the game object is selected to determine
object placement if there is a hit on a surface.
Declaration
protected RayStep CurrentRay
Field Value
Declaration
protected bool DidHitSurface
Field Value
Declaration
protected float DoubleClickTimeout
Field Value
Declaration
protected float LastTimeClicked
Field Value
Properties
If true, the game object to place will start out selected. The object will immediately start
following the TrackedTargetType (Head or Controller Ray) and then a tap is required to place the object.
This value must be modified before Start() is invoked in order to have any effect.
Declaration
public bool AutoStart { get; set; }
Property Value
If true and in the Unity Editor, the normal of the raycast hit will be drawn in yellow.
Declaration
public bool DebugEnabled { get; set; }
Property Value
The default distance (in meters) an object will be placed relative to the TrackedTargetType forward in the SolverHandler.
The GameObjectToPlace will be placed at the default placement distance if a surface is not hit by the raycast.
Declaration
public float DefaultPlacementDistance { get; set; }
Property Value
The current game object layer before it is temporarily switched to IgnoreRaycast while placing the game object.
Declaration
protected int GameObjectLayer { get; set; }
Property Value
If true, the game object to place is selected.
Declaration
public bool IsBeingPlaced { get; protected set; }
Property Value
Declaration
protected bool IsColliderPresent { get; }
Property Value
If true, the game object to place will remain upright and in line with Vector3.up
Declaration
public bool KeepOrientationVertical { get; set; }
Property Value
Array of LayerMask to execute from highest to lowest priority. First layermask to provide a raycast hit will be used by component.
Declaration
public LayerMask[] MagneticSurfaces { get; set; }
Property Value
Type |
Description |
LayerMask[] |
|
The max distance (in meters) to place an object if there is a raycast hit on a surface
Declaration
public float MaxRaycastDistance { get; set; }
Property Value
This event is triggered once when the game object to place is selected.
Declaration
public UnityEvent OnPlacingStarted { get; set; }
Property Value
Type |
Description |
UnityEvent |
|
This event is triggered once when the game object to place is unselected, placed.
Declaration
public UnityEvent OnPlacingStopped { get; set; }
Property Value
Type |
Description |
UnityEvent |
|
If false, the game object to place will not change its rotation according to the surface hit. The object will
remain facing the camera while IsBeingPlaced is true. If true, the object will rotate according to the surface normal
if there is a hit.
Declaration
public bool RotateAccordingToSurface { get; set; }
Property Value
The distance between the center of the game object to place and a surface along the surface normal, if the raycast hits a surface.
Declaration
public float SurfaceNormalOffset { get; set; }
Property Value
Methods
Declaration
public void OnPointerClicked(MixedRealityPointerEventData eventData)
Parameters
Type |
Name |
Description |
MixedRealityPointerEventData |
eventData |
|
Declaration
public void OnPointerDown(MixedRealityPointerEventData eventData)
Parameters
Type |
Name |
Description |
MixedRealityPointerEventData |
eventData |
|
Declaration
public void OnPointerDragged(MixedRealityPointerEventData eventData)
Parameters
Type |
Name |
Description |
MixedRealityPointerEventData |
eventData |
|
Declaration
public void OnPointerUp(MixedRealityPointerEventData eventData)
Parameters
Type |
Name |
Description |
MixedRealityPointerEventData |
eventData |
|
Declaration
protected virtual void PerformRaycast()
Change the position of the game object if there was a hit, if not then place the object at the default distance
relative to the TrackedTargetType origin position
Declaration
protected virtual void SetPosition()
Declaration
protected virtual void SetRotation()
Declaration
public override void SolverUpdate()
Overrides
Declaration
protected override void Start()
Overrides
Start the placement of a game object without the need of the OnPointerClicked event. The game object will begin to follow the
TrackedTargetType (Head by default) at a default distance. StopPlacement() must be called after StartPlacement() to stop the
game object from following the TrackedTargetType. The game object layer is changed to IgnoreRaycast temporarily and then
restored to its original layer in StopPlacement().
Declaration
public void StartPlacement()
Stop the placement of a game object without the need of the OnPointerClicked event.
Declaration
public void StopPlacement()
Implements
MonoBehaviour
IMixedRealityPointerHandler