Can't add material override component to runtime generated mesh renderer entity

In my prefab I’ve added the authoring for the material override component.

I want to set a shader parameter called isHit to toggle a white emission on my player character.

I’ve tried making a custom baker system to add the override component to the entities with render mesh within the root entity, but it didn’t work.



The circled Entity is an Entity that is appearing when I press play. The mesh renderer is attached to the gameobject called Bearsona.

I’m not sure how to bake the override component into here since it seems like this entity is created during baking or something. Here is the inspector for it.

@Rukhanka maybe this is something specific to Rukhanka?

Hi. No this is not related to Rukhanka. Try to remove ‘EntityManager.HasComponent’ check from your baking loop. Additional entities buffer containing only render submeshes (unless you are not creating some custom entities, but, as I see from hirarchy screenshot, you are not).

Ahh okay! Do you have any idea where this circled entity is coming from? It’s not in my prefab and I couldn’t find any Unity documentation on the creating of an MeshRendererEntity

Skinned mesh baking system creates additional entities for every submesh in original SkinnedMeshRenderer. All those entities are parented to skinned mesh bone entity.

To add further context, this happens in the SkinnedMeshRendererBaker, even if you have submesh sharing enabled. There’s no way to identify this entity without either fetching the root reference yourself (which isn’t always defined correctly) or walking the hierarchy in the baking system.

It is yet another thing I fixed in Kinemation. Adding material property overrides to the entity corresponding to the one GameObject with the SkinnedMeshRenderer just works.

@DreamingImLatios I definitely will check that out!

In your expertise, since that entity is created during live baking do you know how to make a system to query that entity? Is it a baking system?

Do you have any examples of using the root or walking the hierarchy I’m not exactly sure what you mean by those

It would be either a baking system, or you would need to do it at runtime. I generally try to avoid giving suggestions about how to do things in baking systems, as they are extremely error-prone and require in-depth knowledge of all the edge cases with incremental baking and reversions and data dependencies in order to make them behave correctly.

I can’t really give you an example either because I fixed the fundamental issue in my framework and don’t need this workaround. My example of how I would do this would just be an authoring component and a baker that adds the material property component. Nothing else.