- I have base class used in the editor which has an abstract method that should give me a component. For technical reasons I can’t specify the exact return type(these classes are stored in a [SerializeReference] List), so I believe I need to return the component as IComponentData.
How can I add this component to an entity? When I try to add with EntityManager, I get
- Given an unknown(but defined) IComponentData, how can I check if an entity has this component?
Example for #1:
public abstract class ConsiderationAuthoring {
public string Description;
public abstract IComponentData Convert();
}
public class ConsiderHealthAuthoring : ConsiderationAuthoring {
public AnimationCurve Curve;
public float Range;
public override IComponentData Convert() {
// Some code creating the component I need
}
}
[CreateAssetMenu(menuName="IAUS/Action")]
public class ActionSO : ScriptableObject {
[SerializeReference, SelectType(typeof(ConsiderationAuthoring))]
public List<ConsiderationAuthoring> Considerations;
// Example of adding component, just for testing
public void OnEnable() {
foreach(ConsiderationAuthoring consideration in Considerations) {
var component = consideration.Convert();
// ?
}
}
}