Is there a way to exempt objects under an object with StaticOptimizeEntity?

I have a request from our artists asking if they could exempt some objects under an object with StaticOptimizeEntity. The way they structure the scene is they have one root where they place StaticOptimizeEntity, then they place the other objects under this one. The hierarchy becomes big at some point so they don’t want to mess with the parent child relationships. However, there are cases where they want to add some simple procedural animations to child objects like rotations and looping lerp movements. These wouldn’t work if the object is under a StaticOptimizeEntity. The solution right now is they would take these objects out and put them outside the static root. But this is cumbersome as they have to position these objects by hand without the proper hierarchy like in the static objects. When the static objects are moved, they also have to manually move the non static objects.

I was wondering if there’s a way to make exemptions during baking. Like maybe we could create a component and when this is encountered, I could take it out from the static root and just set its world position and rotation.

Using a ParentConstraint might work but I have yet to ask if it’s too different from what they know.

You probably want to stop using StaticOptimizeEntity. Here’s what it does and the alternative ways you can do things:

  1. It disables per-object motion vectors. You can disable that in each MeshRenderer instead.
  2. It unparents child submesh entities. Turn on submesh sharing, as this is often way more performant anyways.
  3. It overrides TransformUsageFlags to automatically force world-space. Use TransformUsageFlags properly, and you won’t need this.
  4. It disables per-frame lookups of LODs. You can do this at runtime yourself by doing what FreezeStaticLODObjects.cs does. However, the fact that Unity’s LOD algorithm has these random-access lookups to begin with is disappointing. I have a custom implementation that does not require this.
1 Like