Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question DrawMeshInstancedIndirect Example Does Not Work

Discussion in 'Documentation' started by therealnit, Apr 10, 2023.

  1. therealnit

    therealnit

    Joined:
    Apr 6, 2023
    Posts:
    5
    Hi All. I have been having some issues getting my code using DrawMeshInstancedIndirect to work, namely with the script running but no visible instances being generated. I tried using the official example code found here to see if that would work, but I ran into another error.

    I copied over both the script and surface shader examples, set up a game object as the renderer, created a material with GPU Instancing enabled, and provided the default cube mesh in the settings. The script ran, but the only visible instance of the cube in the scene and game view was centered directly at the game object and glowing pink for a shader-material issue. The game view mentioned that the instances had been created, and when I added a terrain below I could see shadows being cast from all the instances, but I could not see the instances.

    I am not sure what is causing this. If anyone has any advice, that would be greatly appreciated.

    DrawMeshInstancedIndirect Example.png