Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

CreateAdditionalEntity is Really Slow

Discussion in 'Entity Component System' started by RoughSpaghetti3211, Feb 21, 2020.

  1. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,697
    Is anyone else finding CreateAdditionalEntity to be extremely slow ? Is there a better way of doing this ?

    Code (CSharp):
    1.  
    2. for (int i = 0; i < buildProxyData.vertexCount; i++)
    3. {
    4.     Entity eTile = CreateAdditionalEntity(containerProxyData);
    5.     new PlanetTileGraphComponent
    6.     {
    7.         TileId = containerProxyData.id
    8.     };
    9. }
    10.  
    11.  
     
    Last edited: Feb 21, 2020
  2. apkdev

    apkdev

    Joined:
    Dec 12, 2015
    Posts:
    277
    OK, yeah, now I see what you mean. It is ridiculously slow (compared to the other stuff I'm doing during conversion, which is procedurally spawning a couple thousand objects...), even if you use the overload with the
    NativeArray<Entity>
    argument. Is there any workaround for properly spawning entities (during conversion)?

     
  3. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,753
    While a fast workflow is convenient, at the end of the day conversion is not meant to be fast as it's not meant to be done at runtime - it's precomputed work.
     
  4. s_schoener

    s_schoener

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    81
    We have fixed a pretty severe performance bug in this particular function recently (I think it should already be in the latest release). Also, when you create a lot of entities, consider using the new overload that allows you to create multiple additional entities at once.