Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Set the transparent/Cutout/VertexLit shader property

Discussion in 'Shaders' started by SimonAlkemade, Feb 22, 2011.

  1. SimonAlkemade

    SimonAlkemade

    Joined:
    Feb 4, 2009
    Posts:
    432
    How do I set the transparent/Cutout/VertexLit shader property Alpha cutoff from code.

    I have to have something like renderer.material.shader.alphaCutoff = myValue;
    I tried things like:
    renderer.material.SetFloat("AlphaCutoff", Random.Range(0.0f,1.0f));
    But the shader property doesn't seem to exist when I try to access it i code.

    How do I get and set a shader property from code?
     
    Last edited: Feb 22, 2011
  2. SimonAlkemade

    SimonAlkemade

    Joined:
    Feb 4, 2009
    Posts:
    432
    found the solution renderer.material.SetFloat("_Cutoff", myValue);
    :)
     
  3. kondrup

    kondrup

    Joined:
    Apr 23, 2009
    Posts:
    205
    Hi, Do you now what to write and where? if you want cull off (2sided shader)

    I have no problem making it work with the transparent/vertexlit shader using "Cull off" but I can't get the transparent/cutout/vertexlit shader to display both sides.
     
unityunity