うにてぃブログ

主にUnityとC#に関する記事を書いていきます

【Unity】DrawMeshInstanced does not support the shader 'ShaderName' because it does not read any instanced properties. Try switching to DrawMeshInstancedProcedural if the shader is doing procedural instancing.

Graphics.RenderMeshInstanced を利用していたところ以下のエラーが出て原因を探していたところ

DrawMeshInstanced does not support the shader 'ShaderName' because it does not read any instanced properties. Try switching to DrawMeshInstancedProcedural if the shader is doing procedural instancing.

以下のバグフォーラムを見つけて

forum.unity.com

見ていると原因が書いてあり、Unity2021.3.9 の以下の対応で特定の状況でエラーが出るようになったようでした

Shaders: DrawMeshInstanced now provides error feedback when using a shader that does not support instancing. (UUM-6026)

対応が入ったのは以下の Versionらしいので、こちらに更新すれば解決するみたいです

The fix will be in 2021.3.17f1 (to be released approximately on 19 Jan 2023). EDIT (16.12.2022): 2020.3.44f1 will get it as well. 2022.2 and 2023.1 to follow.