Class Prefab
Class that represents a template.
Inherited Members
Namespace: Evergine.Framework.Prefabs
Assembly: Evergine.Framework.dll
Syntax
public class Prefab : DisposableObject, ILoadable, IDependencyObject
Constructors
Prefab(AssetsService, EntityItemModel, Dictionary<Guid, int>)
Initializes a new instance of the Prefab class.
Declaration
public Prefab(AssetsService assetsService, EntityItemModel root, Dictionary<Guid, int> referenceCounter = null)
Parameters
Type | Name | Description |
---|---|---|
Assets |
assetsService | The asset service. |
Entity |
root | The root entity. |
Dictionary<Guid, int> | referenceCounter | The reference counter for this prefab. |
Prefab(AssetsService, Func<Dictionary<Guid, int>, EntityItemModel>)
Initializes a new instance of the Prefab class.
Declaration
public Prefab(AssetsService assetsService, Func<Dictionary<Guid, int>, EntityItemModel> rootGenerator)
Parameters
Type | Name | Description |
---|---|---|
Assets |
assetsService | The asset service. |
Func<Dictionary<Guid, int>, Entity |
rootGenerator | A function that generates the root entity. |
Properties
Dependencies
Gets the list of dependencies.
Declaration
public Lazy<List<IDependencyLink>> Dependencies { get; }
Property Value
Type | Description |
---|---|
Lazy<List<IDependency |
EntityGenerated
Gets a value indicating whether the entity has been generated.
Declaration
public bool EntityGenerated { get; }
Property Value
Type | Description |
---|---|
bool |
Id
Gets or sets the asset ID.
Declaration
public Guid Id { get; set; }
Property Value
Type | Description |
---|---|
Guid | The asset path. |
RawEntity
Gets the original prefab entity.
Declaration
public EntityItemModel RawEntity { get; }
Property Value
Type | Description |
---|---|
Entity |
ReaderVersion
Gets the reader version.
Declaration
public Version ReaderVersion { get; }
Property Value
Type | Description |
---|---|
Version | The reader version. |
ReferenceCounter
Gets the reference count of the assets.
Declaration
public Dictionary<Guid, int> ReferenceCounter { get; }
Property Value
Type | Description |
---|---|
Dictionary<Guid, int> |
Methods
CheckCycles(Guid)
Checks the prefabs for cycles.
Declaration
public bool CheckCycles(Guid prefabId)
Parameters
Type | Name | Description |
---|---|---|
Guid | prefabId | The ID of the prefab that we're checking. |
Returns
Type | Description |
---|---|
bool | True if there are cycles; false otherwise. |
Destroy()
Destroys all resources of this instance.
Declaration
protected override void Destroy()
Overrides
Instantiate()
Instantiates a prefab.
Declaration
public Entity Instantiate()
Returns
Type | Description |
---|---|
Entity | The entity after instantiation. |
Invalidate(ILoadable)
Invalidates this instance and raises the Invalidated event with the new ILoadable instance.
Declaration
public void Invalidate(ILoadable newInstance)
Parameters
ReleaseUnusedMemory()
Releases unused memory.
Declaration
public void ReleaseUnusedMemory()
Events
Invalidated
Occurs when this instance is invalidated and all references must be reloaded.
Declaration
public event EventHandler<ILoadable> Invalidated
Event Type
Type | Description |
---|---|
Event |