Hello, I am trying to change the render mode of my material on a standard shader to cutout mode with the following code:
The code works just fine and the alpha cutoff is set correctly in the inspector, however it doesn’t work on the mesh until I drag it to any other value than 1f, and then back to 1f in the inspector, even if I ran the code through update.
Is there a way it would apply the changes to the material from the code, without requiring me to manually do that?
Thanks in advance!
A material created at runtime does not have all the necessary standard shader keywords enabled. You need to set a bunch of other ones before you have it set as transparent - by dragging the value in the inspector, the editor does this for you, which is why that works.
material.renderQueue = 2450;
This post by Farfarer provides a handy method to make your life easier in regards to this issue.