Search Unity

Convert To Entity - Order?

Discussion in 'Editor & General Support' started by Nuvix, Sep 8, 2021.

  1. Nuvix


    Feb 9, 2014
    What I am trying to achieve:
    • ComponentA is a definition for ComponentC
    • ComponentB is an event signal telling SystemA to create ComponentC from Component A
      • ComponentB has an Entity field, so it knows where to get ComponentA
    • ComponentC is the final product of ComponentA and ComponentB
    I set all of this up in the editor with two GameObjects:
    1. Has ComponentAAuthoring
    2. Has ComponentBAuthoring, which has a GameObject value
    The GameObject field in 2 is set to refer to 1, and both have "Convert to Entity" component set to "Convert And Destroy".

    My authoring components successfully converted these to entities, including the dependence between the original GameObjects. The whole thing was working great, for two days, until I restarted the editor today. Now, the game complains that ComponentA does not exist on entity 1.

    I made no changes to the project.

    Using Debug.Log, I verified that ComponentAAuthoring is no longer running before ComponentBAuthoring, so this must be a problem with conversion order.

    Can I change the order in which GameObjects are converted to entities? Is there a better way to handle dependencies between GameObjects that need to be converted to entities? Or a better way to handle this situation in its entirety?

    I couldn't find anything with Google.

    UPDATE: If I make GameObject 2 a child of GameObject 1, that seems to solve the problem for now. But it is not a viable solution long term, since any particular GameObject could have more than one dependency.
    Last edited: Sep 9, 2021