Class Baker<TAuthoringType>
Inherit this class to bake an authoring component.
Inherited Members
Namespace: Unity.Entities
Assembly: solution.dll
Syntax
public abstract class Baker<TAuthoringType> : IBaker where TAuthoringType : Component
Type Parameters
Name | Description |
---|---|
TAuthoringType | The type of the authoring component. |
Remarks
Use the methods in Baker<TAuthoring
For example you should use Baker<TAuthoring
Examples
public class MyAuthoring : MonoBehaviour
{
public int Value;
}
public struct MyComponent : IComponentData
{
public int Value;
public float3 Position;
}
public class MyBaker : Baker<MyAuthoring>
{
public override void Bake(MyAuthoring authoring)
{
// Accessing the transform using Baker function, not the GameObject one
// so the this baker can keep track of the dependency
var transform = GetComponent<Transform>();
var entity = GetEntity(TransformUsageFlags.Dynamic);
AddComponent(entity, new MyComponent
{
Value = authoring.Value,
Position = transform.position
} );
}
}
Methods
Name | Description |
---|---|
Bake(TAuthoring |
Called in the baking process to bake the authoring component |