Search Unity

Feedback Having an AfterConversion method in systems

Discussion in 'Entity Component System' started by alexandre-fiset, Nov 25, 2019.

  1. alexandre-fiset

    alexandre-fiset

    Joined:
    Mar 19, 2012
    Posts:
    715
    The new [GenerateAuthoringComponent] attribute is nice, but since the OnCreate method of systems is executed before conversion, I think it could be much more powerful if we had at least an AfterConversion overridable method in systems for initialization purpose. Or a [CreateAfterConversion] attribute. Or else, but something ;p

    My reasoning: IConvertGameObjectToEntity can be used to initialize variables. GameObjectConversionSystem can be used to initialize variables, and also to control the order of the conversion. With both [GenerateAuthoringComponent] and AfterConversion method, initialization can happen in systems, and also follow a specific order. Whereas [GenerateAuthoringComponent] alone can't do anything more than have default values. For instance, I cannot create a buffer out of an array or anything that requires bits of code before systems are run.

    OnStartRunning happens after conversion but is not reliable as it may happen several times per system depending on filters and etc.

    Or maybe have I missed something?