Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Change the Surface Type of a Material

Discussion in 'General Graphics' started by adriendupoux31, Sep 9, 2021.

  1. adriendupoux31

    adriendupoux31

    Joined:
    Sep 9, 2021
    Posts:
    1
    I had to change the the surface Type of my material ( Opaque -> Transparent ) by Script
    For the cript i have use :
    Code (CSharp):
    1.  MatMedicalBed01.SetFloat("_Surface", true ? MATERIAL_OPAQUE : MATERIAL_TRANSPARENT);
    2.         MatMedicalBed01.SetShaderPassEnabled("SHADOWCASTER", !true);
    3.         MatMedicalBed01.renderQueue = true ? 3000 : 2000;
    4.         MatMedicalBed01.SetFloat("_DstBlend", true ? 10 : 0);
    5.         MatMedicalBed01.SetFloat("_SrcBlend", true ? 5 : 1);
    6.         MatMedicalBed01.SetFloat("_ZWrite", true ? 0 : 1);
    7.         MatMedicalBed01.color = new Color(1f, 1f, 1f, 1f);
    This script Works by the way, but there is a bug, I have created a fonction Start so that the Material have a Surface type (Opaque). So when i restart the game in Unity, it works but visually it stay on transparent Surface type.
    I just have to click in the object who contains the material and he switch immedialty on Opaque mode.
    I believe it's a bug but i want to fix it. Unfortunately i don't know how to do it.

    Maybe you have any suggestions to solve it ?

    Thanks a lot