Skip to main content

Events API

The Events API allows you set events in capture mode which will be triggered only in Replay mode.

Luna.Replay.Api.Events

For example, if your UI is not compatible with all resolutions but you want to trigger an event in Replay mode regardless of the input, you may use the Events API.

The API has the following methods:

Events.SetEvent( string name, Action callback = null );

Events.Subscribe( string name, Action callback );

Events.Unsubscribe( string name, Action callback );

Example:

public class ExampleClass : MonoBehaviour {
private int test;

private void Start() {
Events.Subscribe( "Test", Log );
}

private void Update() {
if ( Input.GetMouseButton( 0 ) ) {
Events.SetEvent( "Test", Log );
}
}

private void Log() {
Debug.Log( $"Test Log {test++}!" );
}
}