Events - WEKIT-ECS/MIRAGE-XR GitHub Wiki

[!WARNING]
Documentation from before the rewrite, so this may have changed. Check lib-lee for details.

EventManager (lib-lee)

At the moment, the EventManager class works as a central dispatcher for all events. In the future, we seek to move these events into the relevant Managers themselves (new ActivityManager).

Subscribing is simple, as these are static events, so can be called directly from the class:

void Start() {
   EventManager.OnSaveActivity += mySaveRoutine;
}

void onDestroy() {
   EventManager.OnSaveActivity -= mySaveRoutine;
}

private void mySaveRoutine() {
   // I am saving my data
}

Basic workflow

To keep this diagram simple, lots of events have been excluded. This only illustrates the basic flow.

graph TD
    subgraph phase1 [Loading]
        direction LR
        A(OnActivityOpen)
        A --> B(OnActivityLoadedStamp)
    end
    subgraph phase7 [Editor]
        subgraph phase2 [Updating]
            direction LR
            B --> C(OnActionCreated)
            C --> D(OnCreatePoiObject)
        end
        subgraph phase3 [Saving]
            direction LR
            D --> E(OnSaveActivity)
            E --> F(OnActivitySaved)
        end
    end
    subgraph phase6 [Player]
        direction LR
        subgraph phase4 [Executing]
        direction LR
        B --> G(OnActivateAction)
        G --> H(OnToggleObject true)
        end
        subgraph phase5 [Closing]
        direction LR
        H --> I(OnToggleObject false)
        I --> J(OnDeactivateAction)
        end
    end
    subgraph phase9 [Decommissioning]
        direction LR
        J --> K(OnResetPlayer)
        F --> K
    end

Events

There are many events. They are listed below, ordered by purpose:

Global Events

The global events have to do with resetting the player and triggering initialization of the user interface views, which are handled outside of lib-lee. Moreover, there is an important toggle event that switches between the authoring mode of MirageXR and the player: OnEditModeChanged.

Global Events Description
OnResetPlayer / ResetPlayer Fired by ActivityManager after loading the activity to clear the data model gameobjects and content augmentation instances in the scene (calling ClearAll)
OnInitUi / InitUI Trigger user interface
OnClearAll / ClearAll Fires to remove all augmentations from the scene
OnEditModeChanged / NotifyEditModeChanged Triggered by views outside of lib-lee to switch between PlayMode and EditMode

Activity Events

Activity events deal with loading, starting, and saving the activity. As only the repository knows if an activity is existing already (at the moment), there are callbacks to trigger a view dialogue (outside of lib-lee) for asking the user what to do: overwrite, clone, or abort.

Activity Events Description
OnActivityLoadedStamp / ActivityLoadedStamp Loading of activity data model successfully concluded
OnStartActivity / Start Activity Fired by ActivityManager when starting the activity, after restoring the state, and before activating the first action
OnSaveActivity / SaveActivity Save the activity
OnActivitySaved / ActivitySaved Activity saving concluded successfully
OnActivityRenamed / ActivateObject Activity was renamed
OnShowUploadWarningPanel / ShowUploadWarningPanel Trigger user dialogue to confirm whether an existing activity should be overwritten or cloned
OnShowCloneWarningPanelDelegate / ShowCloneWarningPanelDelegate Trigger user dialogue to confirm whether an existing activity should be overwritten or cloned
OnActivityCompletedStamp / ActivityCompletedStamp Triggered by view to indicate that user successfully reached the end of the activity, used for xAPI statement (and update of the restore record for the activity?)

Workplace Events

Workplace events consist of two types. The first has to do with the direct loading and parsing of the workplace data model. The second, more important, handles its instantiation into game objects. This includes containers to hold the content model game objects (including invisible parts such as detectables: anchor positions). This is heavily interacting with the WorkplaceController in MirageXR and the WorkplaceObjectFactory.

Workplace Data Change Events Description
OnWorkplaceLoaded / WorkplaceLoaded Loading of the workplace data model successfully concluded and the data model gameobject containers now exist in the hierarchy
OnCalibrateWorkplace / CalibrateWorkplace Fire event to trigger calibration (outside lib-lee by CalibrationManager)
OnWorkplaceCalibrated / WorkplaceCalibrated Loading of the workplace data model successfully concluded
OnSetPoseSynchronizerTargetToCalibrationAnchor / SetPoseSynchronizerTargetToCalibrationAnchorDelegate Used my WorkplaceManager to hand through the PoseSynchronizer object, to set the target to CalibrationManager anchor
OnInitializeWorkplaceView / InitializeWorkplaceView Call to initialize workplace view controller (outside lib-lee)to set up containers (WorkplaceManager), task stations (WorkplaceController) and augmentations (WorkplaceObjectFactory)
OnTaskStationCloned / NotifyTaskStationCloned Callback to allow awaiting fetching the addressable reference and cloning the task station into the Scene
OnCreateDetectableObject / CreateDetectableObject Callback to allow awaiting creation of the task station (see above)
OnCreatePlaceObject / CreatePlaceObject Callback to allow awaiting creation of the task station (see above)
OnWorkplaceControllerInitialized / NotifyWorkplaceControllerInitialized Call when the workplace view controller (outside lib-lee) has initialized all view instances (including containers and augmentations)
OnDestroyDetectables / DestroyDetectables Decommissioning callback to remove detectables gameobjects from the hierarchy (to free the player for loading a new activity)
OnClearPois / OnClearPois Callback for CalibrationManager to allow clearing the content augmentation location pairs, before loading a new activity
OnDisableAllPoiEditors / DisableAllPoiEditors Disable all editor panels currently open (needed when deleting a content augmentation)

Action Step Events

All the events that have to do with creating, reading, updating, deleting of action steps, as well as instantiating (activate/deactivate). And some data field events: step title changed and description changed.

Step Events Description
OnStepActivated / StepActivated The step was activated
OnStepActivatedStamp / StepActivatedStamp Time stamping events: The step was activated (used for xAPI)
OnStepDeactivatedStamp / StepDeactivatedStamp Time stamping events: The step was deactivated (used for xAPI)
OnActionCreated / NotifyActionCreated Finished creating the new action step
OnActionModified / NotifyActionModified The action step was modified
OnActionDeleted / NotifyActionDeleted Finished deleting the action step
OnActivateAction / ActivateAction Activates a new action
OnDeactivateAction / DeactivateAction Activates a new action
OnActionStepTitleChanged / NotifyOnActionStepTitleChanged Step title was changed
OnActionStepDescriptionChanged / NotifyOnActionStepDescriptionChanged Step description was changed
OnMarkCompleted / MarkCompleted Step marked as completed

ContentAugmentation Events

The events around instantiating content augmentations (OnCreatePoiObject / AugmentationPoiChanged should rather be called OnCreateContentAugmentation and OnContentAugmentationAnchorChanged), as well as deleting, restoring positions, locking them. OnToggleObject uses sadly the same call for activating and deactivating content augmentations in the game object hierarchy, adding a lot of complexity to the connected managers.

Augmentation Events Description
OnCreatePoiObject / CreatePoiObject Async task to allow creating of the parent object holding a content augmentation (game object name starting with 'AN-'
AugmentationPoiChanged / NotifyOnAugmentationPoiChanged User finished moving the location of an augmentation
OnToggleObject (true) / ActivateObject Activate Augmentation
OnToggleObject (false) / DeactivateObject Deactivate Augmentation
OnAugmentationDeleted / NotifyAugmentationDeleted The augmentation was deleted
OnAugmentationRestored / NotifyAugmentationRestored The augmentation was restore
OnAugmentationLocked / NotifyAugmentationLocked The augmentation is now locked, preventing it from being moved

ContentAugmentation-specific Events

Augmentation-specific Events Description
OnCompletedMeasurement / NotifyOnCompletedMeasuring Functionality of the measure action glyph: User completed a measurement

Trigger Events

Trigger Events Description
OnTap / Tap Trigger?
OnClick / Click Obsolete?
OnNext / Next User pressed 'next'