Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Change Base Color Map of HDRP material from scrip

Discussion in 'Scripting' started by ashtronaut, Nov 25, 2020.

  1. ashtronaut

    ashtronaut

    Joined:
    Mar 18, 2020
    Posts:
    5
    I'm trying to change the texture of my material like below, and in the editor window, I see it changing, but in game it doesn't. Is there another method that needs to be called or a flag that needs to be set to see the texture show up in game? I've attached a picture of my editor window, where the texture is set, but the mesh is still gray.

    Code (CSharp):
    1. GetComponent<MeshRenderer>().material.SetTexture("_BaseColorMap", texture);
     

    Attached Files:

  2. ashtronaut

    ashtronaut

    Joined:
    Mar 18, 2020
    Posts:
    5
    NVM, figured it out. I was setting it correctly, but the Metallic property was way low so ig it just wasn't visible lol.