RealtimeModel
Events
event Action<RealtimeModel, int> ownerIDSelfDidChange
Dispatched when the ownerIDSelf value changes.
Properties
bool isFreshModel { get; }
True if this model was just locally created. This flag can be used to apply component settings or initial values to a newly instantiated model.
bool hasMetaModel { get; }
True if the model has a meta-model. A meta-model is required for a client to take ownership of a model. You can add a meta-model to a custom model with the `createMetaModel` flag on the `RealtimeModel` attribute.
bool preventOwnershipTakeover { get; set; }
If true, the model owner must clear ownership before another client can request it.
bool isPersistent { get; }
If true, the object will persist after all clients leave the room.
bool destroyWhenLastClientLeaves { get; set; }
If true, the model is destroyed when the last client in the room leaves.
bool destroyWhenOwnerLeaves { get; set; }
If true, the model is destroyed when the owner of the model leaves the room.
Room room { get; }
The room managing this model, or null if this model is disconnected.
bool isRoomConnected { get; }
True if a room is set on this model and the room is connected.
int ownerIDSelf { get; }
The client ID of the model owner. If the model is unowned, this returns -1.
int ownerIDInHierarchy { get; }
The client ID of the model in its hierarchy. This is the furthest owned ancestor without owned ancestors. If the model and all of its ancestors are unowned, this returns -1.
bool isUnownedSelf { get; }
True if this model is not owned by any client.
bool isUnownedInHierarchy { get; }
True if this model and all of its parent models are not owned by any client.
bool isOwnedRemotelySelf { get; }
True if this model is owned by a remote client.
bool isOwnedRemotelyInHierarchy { get; }
True if this model or any of its parents are owned remotely.
bool isOwnedLocallySelf { get; }
True if this model is owned by the local client.
bool isOwnedLocallyInHierarchy { get; }
True if this model or any of its parents are owned locally.
Methods
void RequestOwnership(bool sendRedundantUpdates = false)
Request ownership of the model. This has no effect if the model has no meta-model. This will throw an exception if the model is not part of a connected room, as it requires the local clientID.
- sendRedundantUpdates: If true, send the ownership update even if the model is already owned by the local client. This might send redundant updates but is useful if you expect contention. This does not circumvent the "Prevent Ownership Takeover" lifetime flag if it applies.
void SetOwnership(int ownerID, bool sendRedundantUpdates = false)
Set ownership of the model to a specific client. This has no effect if the model has no meta-model.
- ownerID: The client ID of the new owner.
- sendRedundantUpdates: If true, send the ownership update even if the model is already owned by the specified ownerID. This might send redundant updates but is useful if you expect contention. This does not circumvent the "Prevent Ownership Takeover" lifetime flag if it applies.
void ClearOwnership(bool sendRedundantUpdates = false)
Clear ownership of the model.
- sendRedundantUpdates: If true, send the ownership update even if the model is already unowned. This might send redundant updates but is useful if you expect contention. This does not circumvent the "Prevent Ownership Takeover" lifetime flag if it applies.