class MAGES::InteractionSystemModule

Overview

The interaction system module base class. More…

class InteractionSystemModule: public MAGES::HubModule
{
public:
    // enums

    enum InteractorCollisionMode;

    // classes

    class InteractableInfo;
    class InteractorInfo;

    // properties

    GameObject LeftHand;
    GameObject LeftHandPrefab;
    GameObject RightHand;
    GameObject RightHandPrefab;
    GameObject Avatar;
    GameObject AvatarPrefab;
    InteractorCollisionMode InteractorsCollisionMode;
    bool ForceRaycastEnabled;
    bool ForceRaycastOn;
    bool IsRaycastForcedOff;
    List<InteractableInfo> Interactables;
    List<InteractorInfo> Interactors;
    List<ILocomotionProvider> ActiveLocomotionProviders;
    AudioClip DefaultHoverEnterSound;
    AudioClip DefaultSelectEnterSound;
    AudioClip DefaultActivateEnterSound;
    float DefaultUIHoverEnterHapticIntensity;
    float DefaultHoverEnterHapticIntensity;
    float DefaultSelectEnterHapticIntensity;
    float DefaultActivateEnterHapticIntensity;
    bool AutomaticPlayerRigSetup;

    // methods

    virtual bool TryAddInteractable(
        GameObject gameObject,
        string interactableType,
        out IInteractable component
    );

    virtual IInteractable GetInteractable(
        GameObject gameObject,
        string interactableType
    );

    virtual IInteractable GetOrAddInteractable(
        GameObject gameObject,
        string interactableType
    );

    virtual IInteractable AddGrabbable(GameObject gameObject);
    virtual IInteractable GetGrabbable(GameObject gameObject);
    virtual IInteractable GetOrAddGrabbable(GameObject gameObject);

    virtual bool TryAddInteractor(
        GameObject gameObject,
        string interactorType,
        out IInteractor component
    );

    virtual IInteractor GetInteractor(GameObject gameObject, string interactorType);
    void ForceRaycast(bool enabled);
    void StopForceRaycast();

    virtual IInteractor GetOrAddInteractor(
        GameObject gameObject,
        string interactorType
    );

    string InteractionLayerToName(int layer);
    int NameToInteractionLayer(string name);

    void GetDefinedInteractionLayers(
        ref string[] layerNames,
        ref int[] layerBitMaskValues
    );
};

// direct descendants

class MAGESInteractionSystem;
class StubInteractionSystem;

Inherited Members

public:
    // properties

    int Version;

    // methods

    void Startup();
    void Shutdown();
    virtual void UpdateModule(UpdatePhase updatePhase);

Detailed Documentation

The interaction system module base class.

Properties

GameObject LeftHand

Gets or sets the left hand gameobject. If the AutomaticPlayerRigSetup is not enabled, this will not be set.

GameObject LeftHandPrefab

Gets or sets the left hand prefab used for automatic setup of the rig if AutomaticPlayerRigSetup is enabled.

GameObject RightHand

Gets or sets the right hand gameobject. If the AutomaticPlayerRigSetup is not enabled, this will not be set.

GameObject RightHandPrefab

Gets or sets the right hand prefab used for automatic setup of the rig if AutomaticPlayerRigSetup is enabled.

GameObject Avatar

Gets or sets the avatar gameobject. If the AutomaticPlayerRigSetup is not enabled, this will not be set.

GameObject AvatarPrefab

Gets or sets the avatar prefab.

InteractorCollisionMode InteractorsCollisionMode

Gets or sets the interactors collision mode.

bool ForceRaycastEnabled

Gets or sets a value indicating whether the raycast is forced to be enabled or disabled.

If set to false (default), the raycast will be enabled or disabled based on the interactor’s settings. If set to true, the raycast will always be enabled regardless of the interactor’s settings.

bool ForceRaycastOn

Gets or sets a value indicating whether the raycast is forced to be on or off.

bool IsRaycastForcedOff

Gets a value indicating whether the raycast is forced to be disabled.

List<InteractableInfo> Interactables

Gets or sets the available interactables for this interaction system.

List<InteractorInfo> Interactors

Gets or sets the available interactors for this interaction system.

List<ILocomotionProvider> ActiveLocomotionProviders

Gets a list with all the currently active locomotion providers.

bool AutomaticPlayerRigSetup

Gets or sets a value indicating whether the player rig will be automatically setup when the scene starts.

Methods

virtual bool TryAddInteractable(
    GameObject gameObject,
    string interactableType,
    out IInteractable component
)

Tries to add the given interactableType script to the gameObject.

Parameters:

gameObject

The gameobject to add the interactable to.

interactableType

The identifier name of the interactable type. See the scriptable object for all available types.

component

The IInteractable component added.

Returns:

true if it was possible to find the given interactableType type and add it to the gameObject.

See also:

GetOrAddInteractable(GameObject, string)

virtual IInteractable GetInteractable(
    GameObject gameObject,
    string interactableType
)

Gets the interactable of the given interactableType from the gameObject.

Parameters:

gameObject

The gameobject to get the component from.

interactableType

The type of the interactable to get.

Returns:

The interactable if found as IInteractable or null if it does not exist.

virtual IInteractable GetOrAddInteractable(
    GameObject gameObject,
    string interactableType
)

Gets the interactable of the given interactableType from the gameObject. If the gameObject does not have this interactable type script, it will be added.

Parameters:

gameObject

The gameobject to get the component from or add it to.

interactableType

The type of the interactable to get or add.

Returns:

The interactable if found or added as IInteractable, or null if the interactableType given is invalid.

See also:

GetInteractable(GameObject, string), GetOrAddGrabbable(GameObject), TryAddInteractable(GameObject, string, out IInteractable)

virtual IInteractable AddGrabbable(GameObject gameObject)

Adds a Grabbable to the gameObject.

Parameters:

gameObject

The GameObject in which to add the Grabbable component.

Returns:

The added grabbable component.

virtual IInteractable GetGrabbable(GameObject gameObject)

Gets the Grabbable from the gameObject.

Parameters:

gameObject

The GameObject to get the Grabbable from.

Returns:

The grabbable if found, else null.

virtual IInteractable GetOrAddGrabbable(GameObject gameObject)

Adds a Grabbable to the gameObject or gets the one already on it.

This is the same as doing it with GetOrAddInteractable(GameObject, string), but is added extra to eliminate typo errors when using strings.

Parameters:

gameObject

The GameObject in which to add the Grabbable component.

Returns:

The Grabbable added or found, as IInteractable.

See also:

GetOrAddInteractable(GameObject, string), GetInteractable(GameObject, string), TryAddInteractable(GameObject, string, out IInteractable)

virtual bool TryAddInteractor(
    GameObject gameObject,
    string interactorType,
    out IInteractor component
)

Tries to add the given interactorType script to the gameObject.

Parameters:

gameObject

The gameobject to add the interactor to.

interactorType

The identifier name of the interactor type. See the scriptable object for all available types.

component

The IInteractor component added.

Returns:

true if it was possible to find the given interactorType type and add it to the gameObject.

See also:

GetOrAddInteractor(GameObject, string)

virtual IInteractor GetInteractor(GameObject gameObject, string interactorType)

Gets the interactor of the given interactorType from the gameObject.

Parameters:

gameObject

The gameobject to get the component from.

interactorType

The type of the interactor to get.

Returns:

The interactor if found as IInteractor or null if it does not exist.

See also:

GetOrAddInteractor(GameObject, string), TryAddInteractor(GameObject, string, out IInteractor)

void ForceRaycast(bool enabled)

Forces the raycast to be enabled or disabled.

Parameters:

enabled

Whether to force them on or off.

void StopForceRaycast()

Stops forcing the raycast to be enabled or disabled.

virtual IInteractor GetOrAddInteractor(
    GameObject gameObject,
    string interactorType
)

Gets the interactor of the given interactorType from the gameObject. If the gameObject does not have this interactor type script, it will be added.

Parameters:

gameObject

The gameobject to get the component from or add it to.

interactorType

The type of the interactor to get or add.

Returns:

The interactor if found or added as IInteractor, or null if the interactorType given is invalid.

See also:

GetInteractor(GameObject, string), TryAddInteractor(GameObject, string, out IInteractor)

string InteractionLayerToName(int layer)

Gets the name of the given interaction layer, if exists or string.Empty otherwise.

Parameters:

layer

The layer.

Returns:

The name of the layer if exists.

int NameToInteractionLayer(string name)

Gets the interaction layer given its name or -1 if it does not exist.

Parameters:

name

The interaction layer name.

Returns:

The interaction layer.

void GetDefinedInteractionLayers(
    ref string[] layerNames,
    ref int[] layerBitMaskValues
)

Gets all the defined Interaction Layers.

Parameters:

layerNames

The names of the layers.

layerBitMaskValues

The Bitmask Values of the layers.