class MAGES::Interaction::Interactors::SimpleUIInteractor

Overview

A simple interactor for UI elements. More…

class SimpleUIInteractor:
    public MonoBehaviour,
    public MAGES::Interaction::IUIInteractor,
    public MAGES::Interaction::Runtime::ILineRenderable
{
public:
    // enums

    enum Input;

    // properties

    Input InputSource;
    Transform RayOrigin;
    float RayLength;
    GameObject Reticle;
    bool ShowLineVisualOnlyWhenPointingUI;

    // methods

    virtual bool CanInteractWithUIs();
    virtual void UpdateUIModel(ref TrackedDeviceModel model);
    void Select();
    void Deselect();

    virtual bool TryGetHitPoint(
        out Vector3 hitPosition,
        out Vector3 hitNormal,
        out int pointIndex
    );

    virtual bool TryGetLinePoints(out Vector3[] points);
    virtual bool TryGetReticle(out GameObject reticle);
    void RegisterWithUIInputModule();
    void DeregisterWithUIInputModule();
};

Inherited Members

public:
    // properties

    Transform RayOrigin;
    float RayLength;

    // methods

    bool CanInteractWithUIs();
    void UpdateUIModel(ref TrackedDeviceModel model);
    bool TryGetLinePoints(out Vector3[] points);

    bool TryGetHitPoint(
        out Vector3 hitPosition,
        out Vector3 hitNormal,
        out int pointIndex
    );

    bool TryGetReticle(out GameObject reticle);

Detailed Documentation

A simple interactor for UI elements.

Properties

Input InputSource

Gets or sets the input source for selecting UI elements.

Transform RayOrigin

Gets the transform from which the Raycast for UIs originates.

float RayLength

Gets the length of the Raycast for UIs.

GameObject Reticle

Gets the reticle to be used when hovering over UI Elements. Will be initialized on Start.

bool ShowLineVisualOnlyWhenPointingUI

Gets or sets a value indicating whether the line should be visible only when hovering over UI elements.

In order for visuals to work a LineVisualizer component must be attached to this GameObject or its children.

Methods

virtual bool CanInteractWithUIs()

Gets a value indicating whether this IUIInteractor has the ability to interact with UIs.

Returns:

true if can hover UIs.

virtual void UpdateUIModel(ref TrackedDeviceModel model)

Updates the UI model with the current state of the interactor.

Parameters:

model

The model to fill with the current state of the IUIInteractor.

void Select()

Select Input for UIInteractor.

void Deselect()

Deselect Input for UIInteractor.

virtual bool TryGetHitPoint(
    out Vector3 hitPosition,
    out Vector3 hitNormal,
    out int pointIndex
)

Gets the hit point of the line.

Parameters:

hitPosition

The position the line hits the object.

hitNormal

The normal at the hit position.

pointIndex

The point index in the line points at which the hit occurs.

Returns:

true if the line hits an object and the object can be interacted.

virtual bool TryGetLinePoints(out Vector3[] points)

Returns a list of the points that make up the line.

Parameters:

points

An array of all the points defining the line.

Returns:

true if able to get at least 2 points (that make a line).

virtual bool TryGetReticle(out GameObject reticle)

Gets the reticle for the line end.

Parameters:

reticle

The reticle gameobject. Forward will be aligned with the normal of the hit point.

Returns:

true if the reticle exists.

void RegisterWithUIInputModule()

Registers to MAGESUIInputModule.

void DeregisterWithUIInputModule()

Deregisters from MAGESUIInputModule.