Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[Bug] ECS disappearing Entities

Discussion in 'Entity Component System' started by howaboutno000, Dec 7, 2020.

  1. howaboutno000

    howaboutno000

    Joined:
    Nov 13, 2020
    Posts:
    20
    This is related to my other thread where I encountered an issue where cubes disappeared out of my view. I've finally boiled it down to the smallest bits.

    I've created a new scene with simplest possible demo which spawns entity cubes in random positions around 0, 0, 0. There is a zip in the attachments. Copy the files into a new project, make sure you have ECS in packages then open the scene in Scenes folder. The entity cubes around spawned all around 0, 0, 0, I put cube "LookHere" there for position reference. Take a look around, rotate your Scene View. You will see that entities are consistently disappearing but for no obvious reason. It's all standard settings, nothing has been changed.
     

    Attached Files:

  2. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    825
    So you should really zip up the entire project folder(sans the Library folder) to make it easier for people to open in the future(the particular version of all packages and editor could have a bearing on any issues you might be having).

    That said, by creating the entity without using conversion you are forgetting to set the RenderBounds and WorldRenderBounds components for your entity. It might be easier to just use conversion with a cube and then use that to instantiate in your loop.
     
  3. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,653
    You need to set only RenderBounds, WorldRenderBounds will set automatically
     
  4. howaboutno000

    howaboutno000

    Joined:
    Nov 13, 2020
    Posts:
    20
  5. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,653
    RenderBounds is a different component. If you spawn entity fully through Instantiate from entity prefab - it will. If you spawn and set everything programmatically - it's up to you. Show entity debugger for your disappearing cubes.
     
    howaboutno000 likes this.
  6. howaboutno000

    howaboutno000

    Joined:
    Nov 13, 2020
    Posts:
    20
    I've given up, I use Instantiate(Entity) now :p. Do Instantiated entities perform nearly as fast as programmatically created entities?
     
  7. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,653
    Depends on how you create programmatically. If you spawn empty entity, add every component step by step, all through EM - it's extremely slow. If you create from archetype - it's nearly the same.