Show / Hide Table of Contents

Class PrefabManager

Manager for handling custom prefabs added to the game.
Inheritance
object
PrefabManager
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Jotunn.Managers
Assembly: Jotunn.dll
Syntax
public class PrefabManager

Properties

Name Description
Instance The singleton instance of this manager.

Methods

Name Description
AddPrefab(GameObject) Add a custom prefab to the manager.
Checks if a prefab with the same name is already added.
Added prefabs get registered to the ZNetScene on ZNetScene.Awake.
AddPrefab(CustomPrefab) Add a custom prefab to the manager.
Checks if a prefab with the same name is already added.
Added prefabs get registered to the ZNetScene on ZNetScene.Awake.
CreateClonedPrefab(string, GameObject) Create a copy of a given prefab without modifying the original.
CreateClonedPrefab(string, string) Create a copy of a given prefab without modifying the original.
CreateEmptyPrefab(string, bool) Create a new prefab from an empty primitive.
DestroyPrefab(string) Destroy a custom prefab.
Removes it from the manager and if already instantiated also from the ZNetScene.
GetPrefab(string) Get a prefab by its name.

Search hierarchy:
  1. Custom prefab with the exact name
  2. Vanilla prefab with the exact name from ZNetScene if already instantiated
  3. Vanilla prefab from the prefab cache
RegisterToZNetScene(GameObject) Register a single prefab to the current ZNetScene.
Checks for existence of the object via GetStableHashCode() and adds the prefab if it is not already added.
RemovePrefab(string) Remove a custom prefab from the manager.

Events

Name Description
OnPrefabsRegistered Event that gets fired after registering all custom prefabs to ZNetScene. Your code will execute every time a new ZNetScene is created (on every game start). If you want to execute just once you will need to unregister from the event after execution.
OnVanillaPrefabsAvailable Event that gets fired after the vanilla prefabs are in memory and available for cloning. Your code will execute every time before a new ObjectDB is copied (on every menu start). If you want to execute just once you will need to unregister from the event after execution.

Extension Methods

PrefabExtension.FixReferences(object)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Generated by DocFX
☀
☾