Class PrefabManager
The prefab manager handles the prefabs creation, synchronization and serialization.
Inheritance
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[Unmanaged]
public static class PrefabManager : Object
Methods
ApplyAll(Actor)
Applies the difference from the prefab object instance, saves the changes and synchronizes them with the active instances of the prefab asset.
Declaration
[Unmanaged]
public static bool ApplyAll(Actor instance)
Parameters
Actor
instance
The modified instance. |
Returns
System.Boolean
True if data is failed to apply the changes, otherwise false. |
Remarks
Applies all the changes from not only the given actor instance but all actors created within that prefab instance.
CreatePrefab(Actor, String, Boolean)
Creates the prefab asset from the given root actor. Saves it to the output file path.
Declaration
[Unmanaged]
public static bool CreatePrefab(Actor targetActor, string outputPath, bool autoLink)
Parameters
Actor
targetActor
The target actor (prefab root). It cannot be a scene but it can contain a scripts and/or full hierarchy of objects to save. |
System.String
outputPath
The output asset path. |
System.Boolean
autoLink
True if auto-connect the target actor and related objects to the created prefab. |
Returns
System.Boolean
True if failed, otherwise false. |
SpawnPrefab(Prefab)
Spawns the instance of the prefab objects. Prefab will be spawned to the first loaded scene.
Declaration
[Unmanaged]
public static Actor SpawnPrefab(Prefab prefab)
Parameters
Prefab
prefab
The prefab asset. |
Returns
Actor
The created actor (root) or null if failed. |
SpawnPrefab(Prefab, Actor)
Spawns the instance of the prefab objects. If parent actor is specified then created actors are fully initialized (OnLoad event and BeginPlay is called if parent actor is already during gameplay).
Declaration
[Unmanaged]
public static Actor SpawnPrefab(Prefab prefab, Actor parent)
Parameters
Prefab
prefab
The prefab asset. |
Actor
parent
The parent actor to add spawned object instance. Can be null to just deserialize contents of the prefab. |
Returns
Actor
The created actor (root) or null if failed. |
SpawnPrefab(Prefab, Actor, Transform)
Spawns the instance of the prefab objects. Prefab will be spawned to the first loaded scene.
Declaration
[Unmanaged]
public static Actor SpawnPrefab(Prefab prefab, Actor parent, Transform transform)
Parameters
Prefab
prefab
The prefab asset. |
Actor
parent
The parent actor to add spawned object instance. Can be null to just deserialize contents of the prefab. |
Transform
transform
The spawn transformation in the world space. |
Returns
Actor
The created actor (root) or null if failed. |
SpawnPrefab(Prefab, Transform)
Spawns the instance of the prefab objects. Prefab will be spawned to the first loaded scene.
Declaration
[Unmanaged]
public static Actor SpawnPrefab(Prefab prefab, Transform transform)
Parameters
Prefab
prefab
The prefab asset. |
Transform
transform
The spawn transformation in the world space. |
Returns
Actor
The created actor (root) or null if failed. |
SpawnPrefab(Prefab, Vector3)
Spawns the instance of the prefab objects. Prefab will be spawned to the first loaded scene.
Declaration
[Unmanaged]
public static Actor SpawnPrefab(Prefab prefab, Vector3 position)
Parameters
Prefab
prefab
The prefab asset. |
Vector3
position
The spawn position in the world space. |
Returns
Actor
The created actor (root) or null if failed. |
SpawnPrefab(Prefab, Vector3, Quaternion)
Spawns the instance of the prefab objects. Prefab will be spawned to the first loaded scene.
Declaration
[Unmanaged]
public static Actor SpawnPrefab(Prefab prefab, Vector3 position, Quaternion rotation)
Parameters
Prefab
prefab
The prefab asset. |
Vector3
position
The spawn position in the world space. |
Quaternion
rotation
The spawn rotation (in world space). |
Returns
Actor
The created actor (root) or null if failed. |
SpawnPrefab(Prefab, Vector3, Quaternion, Vector3)
Spawns the instance of the prefab objects. Prefab will be spawned to the first loaded scene.
Declaration
[Unmanaged]
public static Actor SpawnPrefab(Prefab prefab, Vector3 position, Quaternion rotation, Vector3 scale)
Parameters
Prefab
prefab
The prefab asset. |
Vector3
position
The spawn position in the world space. |
Quaternion
rotation
The spawn rotation (in world space). |
Vector3
scale
The spawn scale. |
Returns
Actor
The created actor (root) or null if failed. |