Photon Fusion 2.1.1

NetworkPrefabTable Class Reference

Class representing a table of network prefabs. More...

Public Member Functions

int AddInstance (NetworkPrefabId prefabId)
 Add an instance of a prefab id.
NetworkPrefabId AddSource (INetworkPrefabSource source)
 Adds a prefab source to the table.
void Clear ()
 Clear the prefab table.
bool Contains (NetworkPrefabId prefabId)
 Returns true if the prefab table contains a prefab with the given id.
IEnumerable<(NetworkPrefabId, INetworkPrefabSource)> GetEntries ()
 Returns all entries in the table.
NetworkObjectGuid GetGuid (NetworkPrefabId prefabId)
 Gets a prefab guid by id.
NetworkPrefabId GetId (NetworkObjectGuid guid)
 Gets a prefab id by guid.
NetworkPrefabId GetId (string nameOrPath)
 Gets a prefab id by name or path. If there are multiple prefabs with the same name, the first registered one is returned.
int GetInstancesCount (NetworkPrefabId prefabId)
 Get the instance count of a prefab id.
INetworkPrefabSource GetSource (NetworkObjectGuid guid)
 Gets a prefab source by guid.
INetworkPrefabSource GetSource (NetworkPrefabId prefabId)
 Gets a prefab source by id.
bool IsAcquired (NetworkPrefabId prefabId)
 Signal if a prefab id has been acquired.
NetworkObject Load (NetworkPrefabId prefabId, bool isSynchronous)
 Load a prefab by id.
int RemoveInstance (NetworkPrefabId prefabId)
 Remove an instance of a prefab id.
bool TryAddSource (INetworkPrefabSource source, out NetworkPrefabId id)
 Tries to add a prefab source to the table.
bool Unload (NetworkPrefabId prefabId)
 Unload a prefab by id.
void UnloadAll ()
 Unload all prefabs.
int UnloadUnreferenced (bool includeIncompleteLoads=false)
 Unload all unreferenced prefabs.

Public Attributes

NetworkPrefabTableOptions Options = NetworkPrefabTableOptions.Default
 Options for the NetworkPrefabTable.

Properties

IReadOnlyList< INetworkPrefabSourcePrefabs [get]
 All prefab sources.
int Version [get]
 Prefab table version. Incremented every time a change occurs.

Detailed Description

Class representing a table of network prefabs.

Member Function Documentation

◆ AddInstance()

int AddInstance ( NetworkPrefabId prefabId)

Add an instance of a prefab id.

Parameters
prefabIdId of the prefab.
Returns
The new instance count, or 0 if not found.

◆ AddSource()

Adds a prefab source to the table.

Parameters
sourcePrefab source to add.
Exceptions
ArgumentExceptionThrown if a prefab source with the same guid already exists.

◆ Contains()

bool Contains ( NetworkPrefabId prefabId)

Returns true if the prefab table contains a prefab with the given id.

Parameters
prefabIdId of the prefab.
Returns
True if the prefab table contains a prefab with the given id.

◆ GetGuid()

NetworkObjectGuid GetGuid ( NetworkPrefabId prefabId)

Gets a prefab guid by id.

Parameters
prefabIdId of the prefab source.
Returns
The prefab guid, or default if not found.

◆ GetId() [1/2]

Gets a prefab id by guid.

Parameters
guidGuid of the prefab source.
Returns
The prefab id, or default if not found.

◆ GetId() [2/2]

NetworkPrefabId GetId ( string nameOrPath)

Gets a prefab id by name or path. If there are multiple prefabs with the same name, the first registered one is returned.

Parameters
nameOrPathName of the prefab.
Returns
The prefab id, or default if not found.

◆ GetInstancesCount()

int GetInstancesCount ( NetworkPrefabId prefabId)

Get the instance count of a prefab id.

Parameters
prefabIdId of the prefab.
Returns
The instance count, or 0 if not found.

◆ GetSource() [1/2]

Gets a prefab source by guid.

Parameters
guidGuid of the prefab source.
Returns
The prefab source, or default if not found.

◆ GetSource() [2/2]

INetworkPrefabSource GetSource ( NetworkPrefabId prefabId)

Gets a prefab source by id.

Parameters
prefabIdId of the prefab source.
Returns
The prefab source, or default if not found.

◆ IsAcquired()

bool IsAcquired ( NetworkPrefabId prefabId)

Signal if a prefab id has been acquired.

Parameters
prefabIdId of the prefab.
Returns
True if the prefab id has been acquired.

◆ Load()

NetworkObject Load ( NetworkPrefabId prefabId,
bool isSynchronous )

Load a prefab by id.

Parameters
prefabIdId of the prefab.
isSynchronousIf true, the load will be synchronous.
Returns
The loaded prefab, or null if not found.

◆ RemoveInstance()

int RemoveInstance ( NetworkPrefabId prefabId)

Remove an instance of a prefab id.

Parameters
prefabIdId of the prefab.
Returns
The new instance count, or 0 if not found.

◆ TryAddSource()

bool TryAddSource ( INetworkPrefabSource source,
out NetworkPrefabId id )

Tries to add a prefab source to the table.

Parameters
sourcePrefab source to add.
idId of the prefab source.
Returns
True if the prefab source was added, false otherwise.
Exceptions
ArgumentNullExceptionThrown if source is null.

◆ Unload()

bool Unload ( NetworkPrefabId prefabId)

Unload a prefab by id.

Parameters
prefabIdId of the prefab.
Returns
True if the prefab was unloaded, false otherwise.

◆ UnloadUnreferenced()

int UnloadUnreferenced ( bool includeIncompleteLoads = false)

Unload all unreferenced prefabs.

Parameters
includeIncompleteLoadsIf true, incomplete loads will be unloaded as well.
Returns
The number of prefabs unloaded.