I want to swap an entity's mesh at runtime to show different levels of damage as a work around to DOTS not supporting RenderFeatures nor Blendshapes. BUT, I’m having trouble figuring out how to do it. Below are the approaches I've tried so far:
Approach 1: Add the RenderMeshArray component via an Authoring Script
https://paste.mod.gg/fwaiyoflwsmu/2
My first thought was to simply bake RenderMeshArray component. Looking at the video I attached, you can see that the baker does add the meshes to the RenderMeshArray component as I assign them on the authoring script, while in Edit Mode. However, once I hit play the RenderMeshArray goes back down to 1 element. I think what's going on here is that the MeshFilter or MeshRenderer component might be overriding the baker class I made.
Removing the MeshFilter and MeshRenderer from the object and manually adding all of the rendering components is out of the question because I want the ability to visually position the entities rather than using a spawner script.
Approach 2: Add the meshes post-baking via a System
https://paste.mod.gg/fwaiyoflwsmu/3
So my next approach was to add the meshes post-bake via a System. But I get the following error from the system I wrote:
The type 'Unity.Rendering.RenderMeshArray' cannot be used as type parameter 'T' in the generic type or method 'RefRW<T>'. There is no boxing conversion from 'Unity.Rendering.RenderMeshArray' to 'Unity.Entities.IComponentData'.
I'm not really sure what this means, but I'm assuming it has to do with meshes being managed and that I should be using SystemBase rather than ISystem. But if I use SystemBase then I'm not sure how to access the entities to add the meshes to the RenderMeshArray.
A tool for sharing your source code with the world!
A tool for sharing your source code with the world!