Snippet: Swapping Rendering Mode in Unity 5.0 on Run TimeMarch 2, 2015
If you’ve ever tried to switch the rendering mode of a material in Unity 5.0 on run time, you might have run into some issues with it not updating properly. This is what I thought would do the trick just fine (sidenote: 0 = Opaque, 1 = Cutout, 2 = Fade, 3 = Transparent), but it doesn’t actually update anything (in my case, I wanted to fade out an object).
If you look in the GUI code for the shader (Editor/StandardShaderGUI.cs) you can find the following code that handles the changing of rendering modes, and will show everything you need to solve this.
As you can see, you need to set more variables in order to swap the rendering mode in real-time, so to switch an object from Opaque to Transparent you will have to do the following: