Table of Contents

Class CustomPrefab

Namespace
Nautilus.Assets
Assembly
Nautilus.dll
Represents a class with everything needed to make a custom prefab work.
public class CustomPrefab : ICustomPrefab
Inheritance
CustomPrefab
Implements
Inherited Members
Extension Methods

Constructors

CustomPrefab()

Constructs a custom prefab object.
public CustomPrefab()

CustomPrefab(PrefabInfo)

Constructs a custom prefab object.
public CustomPrefab(PrefabInfo info)

Parameters

info PrefabInfo
The information this prefab will be registered as.

CustomPrefab(string, string, string)

Constructs a custom prefab object with the Info assigned appropriately.
public CustomPrefab(string classId, string displayName, string description)

Parameters

classId string
The class identifier used for the PrefabIdentifier component whenever applicable.
displayName string
The display name for this item.
description string
The description for this item.

CustomPrefab(string, string, string, Sprite)

Constructs a custom prefab object with the Info assigned appropriately.
public CustomPrefab(string classId, string displayName, string description, Atlas.Sprite icon)

Parameters

classId string
The class identifier used for the PrefabIdentifier component whenever applicable.
displayName string
The display name for this item.
description string
The description for this item.
icon Atlas.Sprite
The icon for this item.

CustomPrefab(string, string, string, Sprite)

Constructs a custom prefab object with the Info assigned appropriately.
public CustomPrefab(string classId, string displayName, string description, Sprite icon)

Parameters

classId string
The class identifier used for the PrefabIdentifier component whenever applicable.
displayName string
The display name for this item.
description string
The description for this item.
icon Sprite
The icon for this item.

Properties

Info

The prefab info for this custom prefab.
public required PrefabInfo Info { get; set; }

Property Value

PrefabInfo

OnPrefabPostProcess

Function that will be executed after the Nautilus's basic processing for Prefab has been completed.
public PrefabPostProcessorAsync OnPrefabPostProcess { get; protected set; }

Property Value

PrefabPostProcessorAsync

Prefab

Function which constructs a game object for this prefab.
public PrefabFactoryAsync Prefab { get; protected set; }

Property Value

PrefabFactoryAsync

Methods

AddGadget<TGadget>(TGadget)

Adds a gadget to this custom prefab. A prefab can only hold one Gadget of any given type.
public TGadget AddGadget<TGadget>(TGadget gadget) where TGadget : Gadget

Parameters

gadget TGadget
The gadget to add

Returns

TGadget
A reference to the added gadget.

Type Parameters

TGadget
Type of the gadget.

Exceptions

DuplicateGadgetException
When a Gadget of the given type already exists.

AddOnRegister(Action)

Adds an action that will be called during the registration of the prefab.
public void AddOnRegister(Action onRegisterCallback)

Parameters

onRegisterCallback Action
The action that will be called.

AddOnUnregister(Action)

Adds an action that will be called when this prefab has performed an unregister operation.
public void AddOnUnregister(Action onUnregisterCallback)

Parameters

onUnregisterCallback Action
The action that will be called.

GetGadget(Type)

Gets the gadget instance associated with the specified gadget type attached to this custom prefab.
public Gadget GetGadget(Type gadgetType)

Parameters

gadgetType Type
The type of the gadget to get.

Returns

Gadget
The gadget instance if found, otherwise; null.

GetGadget<TGadget>()

Gets the gadget instance associated with the specified gadget type attached to this custom prefab.
public TGadget GetGadget<TGadget>() where TGadget : Gadget

Returns

TGadget
The gadget instance if found, otherwise; null.

Type Parameters

TGadget
The type of the gadget to get.

Register()

Registers this custom prefab into the game.
public void Register()

RemoveGadget(Type)

Removes the gadget with the specified type.
public bool RemoveGadget(Type gadget)

Parameters

gadget Type
The type of the gadget to remove.

Returns

bool
true if the gadget was successfully found and removed, otherwise; false.
This method returns false if the gadget type was not found in this custom prefab.

RemoveGadget<TGadget>()

Removes the gadget with the specified type.
public bool RemoveGadget<TGadget>() where TGadget : Gadget

Returns

bool
true if the gadget was successfully found and removed, otherwise; false.
This method returns false if the gadget type was not found in this custom prefab.

Type Parameters

TGadget
The type of the gadget to remove.

SetGameObject(PrefabTemplate)

Sets a prefab template as the game object constructor of this custom prefab.
public void SetGameObject(PrefabTemplate prefabTemplate)

Parameters

prefabTemplate PrefabTemplate
The prefab template object to set.

SetGameObject(Func<IOut<GameObject>, IEnumerator>)

Sets a function as the game object constructor of this custom prefab. This is an asynchronous version.
public void SetGameObject(Func<IOut<GameObject>, IEnumerator> prefabAsync)

Parameters

prefabAsync Func<IOut<GameObject>, IEnumerator>
The function to set.

SetGameObject(Func<GameObject>)

Sets a function as the game object constructor of this custom prefab. This is a synchronous version.
public void SetGameObject(Func<GameObject> prefab)

Parameters

prefab Func<GameObject>
The function to set.

SetGameObject(GameObject)

Sets a game object as the prefab of this custom prefab.
public void SetGameObject(GameObject prefab)

Parameters

prefab GameObject
The game object to set.

Remarks

Only use this overload on GameObjects that are loaded from asset bundles without instantiating them. For objects that could be destroyed on scene load, use SetGameObject(Func<GameObject>) instead.

SetPrefabPostProcessor(Action<GameObject>)

Sets a post processor for the Prefab. This is a synchronous version.
public void SetPrefabPostProcessor(Action<GameObject> postProcessor)

Parameters

postProcessor Action<GameObject>
The post processor to set.

SetPrefabPostProcessor(Func<GameObject, IEnumerator>)

Sets a post processor for the Prefab. This is an asynchronous version.
public void SetPrefabPostProcessor(Func<GameObject, IEnumerator> postProcessorAsync)

Parameters

postProcessorAsync Func<GameObject, IEnumerator>
The post processor to set.

TryAddGadget<TGadget>(TGadget)

Attempts to add the given gadget if there is not already an existing gadget of the same type.
public bool TryAddGadget<TGadget>(TGadget gadget) where TGadget : Gadget

Parameters

gadget TGadget
The gadget that may be added, assuming the same type of gadget does not already exist on the prefab.

Returns

bool
True if the gadget was added, false if an instance of the same gadget type already exists on the prefab.

Type Parameters

TGadget
The type of the gadget that may be added.

TryGetGadget<TGadget>(out TGadget)

Gets the gadget instance associated with the specified gadget type attached to this custom prefab.
public bool TryGetGadget<TGadget>(out TGadget gadget) where TGadget : Gadget

Parameters

gadget TGadget
The instance of the gadget found associated with the type. If not found, this will be null instead.

Returns

bool
true if the gadget associated with type was found, otherwise; false.

Type Parameters

TGadget
The type of the gadget to get.

Unregister()

Unregisters this custom prefab from the game.
public void Unregister()

Remarks

The class ID reference will be completely erased, however, the TechType instance will remain in the game.