public class RemoteEventsExample : MonoBehaviour
{
private const byte EVENT_ID = 1;
private void Awake()
{
SpatialBridge.networkingService.remoteEvents.onEvent += OnRemoteEvent;
}
private void OnDestroy()
{
SpatialBridge.networkingService.remoteEvents.onEvent -= OnRemoteEvent;
}
private void OnRemoteEvent(NetworkingRemoteEventArgs args)
{
if (args.eventID == EVENT_ID)
{
string message = args.eventArgs[0] as string;
Debug.Log($"Received remote event with message: {message}");
}
}
public static void Trigger()
{
SpatialBridge.networkingService.remoteEvents.RaiseEventAll(EVENT_ID, "Hello World!");
}
}
public class RemoteEventsExample : MonoBehaviour
{
private const byte EVENT_ID = 1;
private void Awake()
{
SpatialBridge.networkingService.remoteEvents.onEvent += OnRemoteEvent;
}
private void OnDestroy()
{
SpatialBridge.networkingService.remoteEvents.onEvent -= OnRemoteEvent;
}
private void OnRemoteEvent(NetworkingRemoteEventArgs args)
{
if (args.eventID == EVENT_ID)
{
string message = args.eventArgs[0] as string;
Debug.Log($"Received remote event with message: {message}");
}
}
public static void Trigger()
{
SpatialBridge.networkingService.remoteEvents.RaiseEventAll(EVENT_ID, "Hello World!");
}
}