Table of Contents

Interface ICustomPrefab

Namespace
Nautilus.Assets
Assembly
Nautilus.dll
Specifies the contract for a custom prefab.
public interface ICustomPrefab
Extension Methods

Properties

Info

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

Property Value

PrefabInfo

OnPrefabPostProcess

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

Property Value

PrefabPostProcessorAsync

Prefab

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

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.
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.
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.
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.
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.
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.

RemoveGadget(Type)

Removes the gadget with the specified type.
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.
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.

TryAddGadget<TGadget>(TGadget)

Attempts to add the given gadget if there is not already an existing gadget of the same type.
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.
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.