Search Unity

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.