Search Unity

Resolved URP/Material Change 'Render Face' at Runtime, programmatically

Discussion in 'Unity Reflect' started by opacicpetar96, Dec 22, 2020.

  1. opacicpetar96

    opacicpetar96

    Joined:
    Nov 20, 2019
    Posts:
    26
    Hello!

    I would like to change the Render Face property of the materials that uses the Universal Render Pipeline. Now I know how to do this in the Inspector but I would like to access this property from code and change values at runtime. (For example, from Front to Both).
    The property:
    renderface.PNG

    Any ideas?
     
  2. Gublu

    Gublu

    Unity Technologies

    Joined:
    Dec 17, 2020
    Posts:
    9
    Hi,

    You can achieve that by setting the material value "_Cull". Exemple:

    Material mat = [set your TestMat here];
    mat.SetFloat("_Cull", (float)CullMode.Off);
     
  3. opacicpetar96

    opacicpetar96

    Joined:
    Nov 20, 2019
    Posts:
    26
    Thank you @Gublu , this solved the issue! :)