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 SourceInstance
The singleton instance of this manager.
Declaration
public static PrefabManager Instance { get; }
Property Value
Type | Description |
---|---|
PrefabManager |
Methods
| Improve this Doc View SourceAddPrefab(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 .
Checks if a prefab with the same name is already added.
Added prefabs get registered to the
Declaration
public void AddPrefab(GameObject prefab)
Parameters
Type | Name | Description |
---|---|---|
GameObject | prefab | Prefab to add |
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 .
Checks if a prefab with the same name is already added.
Added prefabs get registered to the
Declaration
public void AddPrefab(CustomPrefab customPrefab)
Parameters
Type | Name | Description |
---|---|---|
CustomPrefab | customPrefab | Prefab to add |
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 |
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 |
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 |
DestroyPrefab(String)
Destroy a custom prefab.
Removes it from the manager and if already instantiated also from the .
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 |
GetPrefab(String)
Get a prefab by its name.
Search hierarchy:
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 |
Init()
Creates the prefab container and registers all hooks.
Declaration
public void Init()
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.
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 |
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 SourceOnPrefabsRegistered
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 |
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 |