Skip to main content

PrefabManager

A static class in Root.Township, Alta.Networking.

Static lookup of every NetworkPrefab by hash, loaded from the Network Prefabs resources folder on first use. Use GetPrefab to find a prefab to spawn.

Fields​

2 private and internal fields
MemberWhat it is
private static Logger loggerLogger for this class.
private static Dictionary<uint, NetworkPrefab> prefabMapPrefabs by hash, or null until loaded.

Properties​

MemberWhat it is
static IEnumerable<NetworkPrefab> AllPrefabs { get; }Every loaded prefab. Throws if nothing has loaded the map yet, so call PrepareSpawnSetups first.

Methods​

MemberWhat it is
static bool Exists(uint hash)Whether a prefab with this hash exists.
static NetworkPrefab GetPrefab(uint hash)Finds a prefab by hash, or by string: the hash as text, or the lowercase name with or without spaces. The string is not lowercased for you.
static NetworkPrefab GetPrefab(string name)Finds a prefab by hash, or by string: the hash as text, or the lowercase name with or without spaces. The string is not lowercased for you.
static void PrepareSpawnSetups()Loads all network prefabs once and, on headless builds, strips their meshes, materials, lights and cameras.
4 private and internal methods
MemberWhat it is
private static void AddToPrefabMap(NetworkPrefab[] prefabs)Adds prefabs to the map by hash, logging an error for any duplicate hash.
private static void FindPrefabsOutOfFolder(NetworkPrefab[] prefabs)Empty.
private static void RemoveAllMaterialsAndMeshesOnPrefabs()Headless: clears and disables renderers, meshes, lights and cameras on all resource prefabs to save memory.
private static void ValidateAllEmbeddedHashes(NetworkPrefab[] prefabs)Checks each prefab's embedded entity hashes; not called here.