📓

NetworkEntityPrefabs

[CreateAssetMenu(fileName = "NetworkEntityPrefabs", menuName = "CyborgNetcode/NetworkEntityPrefabs")]
public class NetworkEntityPrefabs : ScriptableObject
{
    
    public List<NetworkEntity> prefabs = new List<NetworkEntity>();
//...

This scriptable object stores a list of your NetworkEntity prefabs and is crucial to your games networked replication. This container is used to let a NetworkEntityManager know what types of Unity prefabs it can build e.g players, bullets etc. So if your game doesn’t haven one, you wont be able to build any NetworkEntities across the network. So for each NetworkEntity Unity gameobject your game needs, make sure to make them a prefab and store them inside a version of this scriptable object.

To build this scriptable object, right click inside your project assets folder somewhere and choose Create→CyborgNetcode→NetworkEntityPrefabs

When its created, select it so that it shows in the property window and then you can drag your

NetworkEntity prefabs into it

We’re not done yet. Any game objects in your game with the NetworkEntityManager class attached need a reference to your NetworkEntitiesPrefab. The example below is from the one of the 2 game map scenes the sample ships with on the BattleNetworkUpdater game object.

Methods

public GameObject GetGameObject(NetworkEntityType prefabType)

Finds a GameObject within the prefabs list matching the type passed in or returns null

public GameObject GetGameObjectByTypeID(int prefabTypeID)

Finds a GameObject within the prefabs list matching the typeID passed in or returns null

public GameObject GetGameObjectByName(string prefabName)

Finds a GameObject within the prefabs list matching the type name passed in or returns null