Search Unity

StaticOptimizeEntity in SubScene locks the chunk, removing the capacity to add/remove components

Discussion in 'Data Oriented Technology Stack' started by maxxa05, Oct 14, 2019.

  1. maxxa05

    maxxa05

    Joined:
    Nov 17, 2012
    Posts:
    113
    So, a few posts talked about this issue, but I couldn't find any response on this. Like the title said, adding a StaticOptimizeEntity on a GameObject in a subscene locks the chunk of the resulting entity. If I try to add or remove a component on an entity created by a GameObject with StaticOptimizeEntity in the subscene, I get the exception:

    InvalidOperationException: Cannot add components to locked Chunks. Unlock Chunk first.


    Is that a bug, or is that by design? It certainly looks broken, since a pretty basic ComponentSystem can break if it acts on locked chunk. Is there a workaround, since I would like to have the optimization of the static component without the limitation of being unable to add and remove components.
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    1,983
    Well isn't that exactly what static means. It can't be changed.

    This seems very useful for someone who actually wants static entities that can't change.
     
  3. maxxa05

    maxxa05

    Joined:
    Nov 17, 2012
    Posts:
    113
    Thing is, it seems it's only happening with subscenes, not ConvertToEntity.

    Also, if that's really by design, I think it should be split into multiple options. An entity that won't ever move is not the same than an entity that cannot be added and removed components, and vice versa. That's 2 very different behaviours.

    And while we're on the subject, I'd like if there was a way to convert a gameobject while removing everything related to the transform, even the LocalToWorld. Sometimes, the transform data is just useless for our use case.
     
unityunity