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

Universal RP Color change code?

Discussion in 'Scripting' started by Lycaena, Mar 29, 2020.

  1. Lycaena

    Lycaena

    Joined:
    Mar 3, 2015
    Posts:
    11
    Hello, I'm sorry for my English.
    I use Universal Pipeline Render. But I can't find a command to change the color of Base Color in the material. Can you help me.

    The code I used to be working was this:

    Code (CSharp):
    1. ArabaKaportasi2.GetComponent<Renderer>().material.color = new Color32(250, 250, 250, 0);
    It doesn't work after switching to Universal Pipline Render. I made a few attempts, but it didn't work, only one color changed a bit with this command but it turns out to be distorted.

    Code (CSharp):
    1. ArabaKaportasi1.GetComponent<Renderer>().material.SetColor("_BaseColor", new Color(250, 250, 250));
    fail...
    help me?

    Adsız.png
     
  2. luisjohnson2023

    luisjohnson2023

    Joined:
    Mar 22, 2023
    Posts:
    2
    hi we can use this Code for fix your Color

    public Material ArabaKaportasi1;
    void Update(){
    test();
    }
    private void test()
    {
    ArabaKaportasi1.SetColor("_BaseColor", new Color(250, 250, 250));
    }
     
  3. luisjohnson2023

    luisjohnson2023

    Joined:
    Mar 22, 2023
    Posts:
    2
    ArabaKaportasi1.SetColor("_BaseColor", new Color(250, 250, 250)); replace this code
    this
    ArabaKaportasi1.SetColor("_BaseColor", new Color32(250, 250, 250,50));