PrefabBuilder
Declaration
public class Strawberry.Core.PrefabBuilder
Builder for constructing prefabs without first creating a template entity.
Methods
WithAssetManager
Sets the AssetManager used to resolve asset → name when Build() is called. Required if any component has asset references that should be serialized by name.
PrefabBuilder WithAssetManager(AssetManager assets)
Parameters:
| Name | Type | Description |
|---|---|---|
assets |
Strawberry.Core.AssetManager |
The asset manager to use |
Returns: The PrefabBuilder to continue the setup
AddComponent
Adds a component to the PrefabBuilder later used to build the Prefab
PrefabBuilder AddComponent<T>(Action<T> configure = null)
Parameters:
| Name | Type | Description |
|---|---|---|
configure |
System.Action = null |
Called after the creation of the component of Type T. Used to configure the component |
Returns: The PrefabBuilder instance to continue the setup
Type Parameters:
T— Type of component to add
AddComponent
Adds an already instantiated component to the PrefabBuilder
PrefabBuilder AddComponent<T>(T component)
Parameters:
| Name | Type | Description |
|---|---|---|
component |
T |
The component instance to add |
Returns: The PrefabBuilder instance to continue the setup
Type Parameters:
T— The Type of the component
Exceptions:
System.ArgumentNullException— Thrown when component is null
Build
Builds the prefab
Prefab Build()