Search Unity

ConvertToEntity bug ?

Discussion in 'Entity Component System' started by filod, Nov 25, 2019.

  1. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    224
    Play around with entities 0.2.0-preview.18, ConvertToEntity's Convert And Inject GameObject is not working now, Gameobjects are always destroyed
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
  3. The-Oddler

    The-Oddler

    Joined:
    Nov 26, 2010
    Posts:
    133
    For those that don't want to read through everything of the link posted above (as most of it is not relevant for this specific problem) here's what they say there:

    This is indeed a bug, and not working normally.

    However, there is a workaround. Since the bug only seems to happen with root object, and we can use that fact to work around the problem:

    1) Create a new root object with a "Convert to Entity" component set to "Convert and Destroy"
    2) Add your current object (with their "Convert to Entity" set to "Convert and Inject") as children to this root object

    Voila, it should work again then.

    In your Hierarchy it will look something like:

    upload_2019-11-25_15-24-46.png

    Where player used to be just a root object, but now is a child of this new parent object. I named it specifically like that so I know it's there for a workaround.

    This new parent object is very simple:

    upload_2019-11-25_15-25-47.png

    The player looks like this:

    upload_2019-11-25_15-26-23.png

    When going into play mode the parent object will be destroyed, but the children will then become root objects. And everything should work like before. I haven't tested this a lot yet, but at first glance it seems to work.
     
    filod and psuong like this.
  4. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,708
    Thank you
     
  5. Fabrice_Lete

    Fabrice_Lete

    Unity Technologies

    Joined:
    May 5, 2018
    Posts:
    55
    Thanks for reporting the issue, the regression has been fixed in the upcoming package update.
     
  6. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    It's fixed in Entities 0.3.0 package