Realtime
Realtime
Realtime manages a Room object and synchronizes its datastore to RealtimeViews and RealtimeComponents in the scene.
Static Properties
IReadOnlyCollection<Realtime> instances { get; }
All of the Realtime instances currently loaded in scenes.
Static Methods
GameObject Instantiate(string prefabName, InstantiateOptions? options)
Instantiates a realtime prefab in the scene on all clients.
The fully instantiated game object. All RealtimeViews and RealtimeComponents, along with their models will be initialized and ready for use immediately.
GameObject Instantiate(string prefabName, Vector3 position, Quaternion rotation, InstantiateOptions? options)
Instantiates a realtime prefab in the scene on all clients.
The fully instantiated game object. All RealtimeViews and RealtimeComponents, along with their models will be initialized and ready for use immediately.
void Destroy(GameObject gameObject)
Destroys a realtime prefab on all clients.
This method must be used instead of GameObject.Destroy(). It can only be used with GameObjects that were instantiated with Realtime.Instantiate().
void Destroy(RealtimeView realtimeView)
Destroys a realtime prefab on all clients.
This method must be used instead of GameObject.Destroy(). It can only be used with GameObjects that were instantiated with Realtime.Instantiate().
Events
event RealtimeEvent didConnectToRoom
An event that is fired when Realtime is connected to a room and all realtime prefabs and realtime views in the scene have been successfully connected to the datastore.
event RealtimeEvent didDisconnectFromRoom
An event that is fired when Realtime is disconnected from a room.
Properties
string roomToJoinOnStart { get; }
The name of the room to join on start if one was configured in the inspector.
This setting can only be configured in the editor inspector. If you'd like to change this name at runtime, disable join room on start, and use the Connect() method on Realtime instead.
bool joinRoomOnStart { get; }
A boolean indicating whether Realtime will try to automatically connect on Start().
This setting can only be configured in the editor inspector. If you'd like to change this name at runtime, disable join room on start, and use the Connect() method on Realtime instead.
NormcoreAppSettings normcoreAppSettings { get; set; }
The app settings object reference used when Realtime connects. Changing this while the Realtime instance is connected will not have any effect until the next time it connects.
Room room { get; set; }
bool connecting { get; }
True if this Realtime instance is in the process of connecting or initializing its views.
bool connected { get; }
True if this Realtime instance is connected and its views are initialized.
bool disconnected { get; }
True if this Realtime instance is not connected or in an error state.
int clientID { get; }
The local clientID of this Realtime instance.
double roomTime { get; }
The server time on this frame. This value has latency from the server removed.
float ping { get; }
The local client's last known ping with the server in milliseconds.
Methods
void Connect(string roomName, RealtimeModel roomModel)
Connect to a room.
void Connect(string roomName, ConnectOptions connectOptions = null)
Connect to a room.
void Disconnect()
Disconnect from a room.