I’m just making a grid of tiles where I could change their tint on click. However,
MeshInstanceRenderer is a shared component data so it affects every other entity that uses it. Is there another way to render that does not use MeshInstanceRenderer?
You can try create your own shader for you material with changeable parameter. Read this (adding per-instance data)
I see. Thanks!
Uhm, how do I set the color exactly? From the documentation, it needs MeshRenderer so it can call SetPropertyBlock().
MeshInstanceRenderer doesn’t have such method.
Hm, It is more complicated that i thought. Sorry.
Maybe for your use case it is better to use simple substitution of tiles with different materials, if it’s possible.
But if you want shader approach, i found this post Can MeshInstanceRenderer do per-instance data and custom draw order?
It seems you can write your own MeshInstanceRenderer, or modify existing one, or wait until developers improve their MeshInstanceRenderer API. You can find MeshInstanceRendererSystem.cs in packages folder of your project, and it has this line of code that does all job
Graphics.DrawMeshInstanced(renderer.mesh, renderer.subMesh, renderer.material, m_MatricesArray, length, null, renderer.castShadows, renderer.receiveShadows);
null parameter is for MaterialPropertyBlock
Cool! Thanks!