Photon Fusion 2.0.3

Public Member Functions | Public Attributes | Properties | List of all members
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. More...
 
NetworkPrefabId AddSource (INetworkPrefabSource source)
 Adds a prefab source to the table. More...
 
void Clear ()
 Clear the prefab table. More...
 
bool Contains (NetworkPrefabId prefabId)
 Returns true if the prefab table contains a prefab with the given id. More...
 
IEnumerable<(NetworkPrefabId, INetworkPrefabSource)> GetEntries ()
 Returns all entries in the table. More...
 
NetworkObjectGuid GetGuid (NetworkPrefabId prefabId)
 Gets a prefab guid by id. More...
 
NetworkPrefabId GetId (NetworkObjectGuid guid)
 Gets a prefab id by guid. More...
 
int GetInstancesCount (NetworkPrefabId prefabId)
 Get the instance count of a prefab id. More...
 
INetworkPrefabSource GetSource (NetworkObjectGuid guid)
 Gets a prefab source by guid. More...
 
INetworkPrefabSource GetSource (NetworkPrefabId prefabId)
 Gets a prefab source by id. More...
 
bool IsAcquired (NetworkPrefabId prefabId)
 Signal if a prefab id has been acquired. More...
 
NetworkObject Load (NetworkPrefabId prefabId, bool isSynchronous)
 Load a prefab by id. More...
 
int RemoveInstance (NetworkPrefabId prefabId)
 Remove an instance of a prefab id. More...
 
bool TryAddSource (INetworkPrefabSource source, out NetworkPrefabId id)
 Tries to add a prefab source to the table. More...
 
bool Unload (NetworkPrefabId prefabId)
 Unload a prefab by id. More...
 
void UnloadAll ()
 Unload all prefabs. More...
 
int UnloadUnreferenced (bool includeIncompleteLoads=false)
 Unload all unreferenced prefabs. More...
 

Public Attributes

NetworkPrefabTableOptions Options = NetworkPrefabTableOptions.Default
 Options for the NetworkPrefabTable. More...
 

Properties

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

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()

NetworkPrefabId AddSource ( INetworkPrefabSource  source)

Adds a prefab source to the table.

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

◆ Clear()

void Clear ( )

Clear the prefab table.

◆ 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.

◆ GetEntries()

IEnumerable<(NetworkPrefabId, INetworkPrefabSource)> GetEntries ( )

Returns all entries in the table.

◆ 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()

Gets a prefab id by guid.

Parameters
guidGuid of the prefab source.
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.

◆ UnloadAll()

void UnloadAll ( )

Unload all prefabs.

◆ 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.

Member Data Documentation

◆ Options

Options for the NetworkPrefabTable.

Property Documentation

◆ Prefabs

IReadOnlyList<INetworkPrefabSource> Prefabs
get

All prefab sources.

◆ Version

int Version
get

Prefab table version. Incremented every time a change occurs.