Unity used to have this, but they removed it.
I suggest autogenerating authoring for trivial components. This would save a lot of work for ECS projects. For example:
// An example component for which we want to
// define an authoring component and a baker.
[GenerateAuthoring]
public struct EnergyShield : IComponentData
{
public int HitPoints;
public int MaxHitPoints;
public float RechargeDelay;
public float RechargeRate;
}
would generate:
// An authoring component for EnergyShield.
// By itself, an authoring component is just an ordinary MonoBehavior.
public partial class EnergyShieldAuthoring : MonoBehaviour
{
public int HitPoint;
public int MaxHitPoints;
public float RechargeDelay;
public float RechargeRate;
// The baker for our EnergyShield authoring component.
// For every GameObject in an entity subscene, baking creates a
// corresponding entity. This baker is run once for every
// EnergyShieldAuthoring instance that's attached to any GameObject in
// the entity subscene.
public class Baker : Baker<EnergyShieldAuthoring>
{
public override void Bake(EnergyShieldAuthoring authoring)
{
// The TransformUsageFlags specifies which transform components the
// entity should have. 'None' means that it doesn't need any.
var entity = GetEntity(TransformUsageFlags.None);
// This simple baker adds just one component to the entity.
AddComponent(entity, new EnergyShield
{
HitPoints = authoring.HitPoints,
MaxHitPoints = authoring.MaxHitPoints,
RechargeDelay = authoring.RechargeDelay,
RechargeRate = authoring.RechargeRate,
});
}
}
}
You could add options such as the name of the authoring component.
Unity used to have this, but they removed it.
I suggest autogenerating authoring for trivial components. This would save a lot of work for ECS projects. For example:
would generate:
You could add options such as the name of the authoring component.