Show / Hide Table of Contents

Class PrefabManager

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

Properties

| Improve this Doc View Source

Instance

The singleton instance of this manager.
Declaration
public static PrefabManager Instance { get; }
Property Value
Type Description
PrefabManager

Methods

| Improve this Doc View Source

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 on .
Declaration
public void AddPrefab(GameObject prefab)
Parameters
Type Name Description
GameObject prefab Prefab to add
| Improve this Doc View Source

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 on .
Declaration
public void AddPrefab(CustomPrefab customPrefab)
Parameters
Type Name Description
CustomPrefab customPrefab Prefab to add
| Improve this Doc View Source

CreateClonedPrefab(String, GameObject)

Create a copy of a given prefab without modifying the original.
Declaration
public GameObject CreateClonedPrefab(string name, GameObject prefab)
Parameters
Type Name Description
System.String name Name of the new prefab.
GameObject prefab Prefab instance to copy.
Returns
Type Description
GameObject Newly created prefab object
| Improve this Doc View Source

CreateClonedPrefab(String, String)

Create a copy of a given prefab without modifying the original.
Declaration
public GameObject CreateClonedPrefab(string name, string baseName)
Parameters
Type Name Description
System.String name Name of the new prefab.
System.String baseName Name of the vanilla prefab to copy from.
Returns
Type Description
GameObject Newly created prefab object
| Improve this Doc View Source

CreateEmptyPrefab(String, Boolean)

Create a new prefab from an empty primitive.
Declaration
public GameObject CreateEmptyPrefab(string name, bool addZNetView = true)
Parameters
Type Name Description
System.String name The name of the new GameObject
System.Boolean addZNetView When true a ZNetView component is added to the new GameObject for ZDO generation and networking. Default: true
Returns
Type Description
GameObject The newly created empty prefab
| Improve this Doc View Source

DestroyPrefab(String)

Destroy a custom prefab.
Removes it from the manager and if already instantiated also from the .
Declaration
public void DestroyPrefab(string name)
Parameters
Type Name Description
System.String name The name of the prefab to destroy
| Improve this Doc View Source

GetPrefab(String)

Get a prefab by its name.

Search hierarchy:
Declaration
public GameObject GetPrefab(string name)
Parameters
Type Name Description
System.String name Name of the prefab to search for.
Returns
Type Description
GameObject The existing prefab, or null if none exists with given name
| Improve this Doc View Source

Init()

Creates the prefab container and registers all hooks.
Declaration
public void Init()
| Improve this Doc View Source

RegisterToZNetScene(GameObject)

Register a single prefab to the current .
Checks for existence of the object via GetStableHashCode() and adds the prefab if it is not already added.
Declaration
public void RegisterToZNetScene(GameObject gameObject)
Parameters
Type Name Description
GameObject gameObject
| Improve this Doc View Source

RemovePrefab(String)

Remove a custom prefab from the manager.
Declaration
public void RemovePrefab(string name)
Parameters
Type Name Description
System.String name Name of the prefab to remove

Events

| Improve this Doc View Source

OnPrefabsRegistered

Event that gets fired after registering all custom prefabs to . 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.
Declaration
public static event Action OnPrefabsRegistered
Event Type
Type Description
System.Action
| Improve this Doc View Source

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 is copied (on every menu start). If you want to execute just once you will need to unregister from the event after execution.
Declaration
public static event Action OnVanillaPrefabsAvailable
Event Type
Type Description
System.Action

Extension Methods

PrefabExtension.FixReferences(Object)
  • Improve this Doc
  • View Source
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾