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

Addressable material

Discussion in 'Addressables' started by Risine, Nov 15, 2020.

  1. Risine

    Risine

    Joined:
    Dec 10, 2009
    Posts:
    154
    Hi,
    I'm loading an addressable prefab containing a mesh object with the renderer using a material/standard shader.
    When I launch the game(even in the editor mode), I load the prefab and changes the material color by script.
    That change is correctly taken into account in play mode in the inspector, but not in the scene, and when I change the color in real time in inspector, it's stil not taken into account, as if the material used was not the one in the inspector.
    Does someone has an idea of what's happening?
    Thanks
     
  2. Wulirocks

    Wulirocks

    Joined:
    Mar 18, 2013
    Posts:
    63
    This sounds like material vs sharedmaterial issue. I had this problem while back...
    Keep an eye on what material the mesh is using. Is it using the sharedmaterial(the one in your assets) or an instance(clone) of that material (it will be written "instance" somewhere in the inspector ). that may be it....
     
  3. Risine

    Risine

    Joined:
    Dec 10, 2009
    Posts:
    154
    Thanks Paul,
    it's written (instance) and when I change its color, nothing happens.
    I can change other parameters though, like the texture, and that's correctly taken into account, meaning it's the right material, but its color parameter is "broken".
     
  4. Wulirocks

    Wulirocks

    Joined:
    Mar 18, 2013
    Posts:
    63
    So you have an object (lets call it "Aobject")with an instanced material on it with its color set to blue in the inspector but the "Aobject" is not blue? do you have something in the editor that may override the color? do you have screenshot of your code?
     
  5. Risine

    Risine

    Joined:
    Dec 10, 2009
    Posts:
    154
    Ok, so I found my problem, nothing to do with addressables ( I thought it worked without them, I was wrong).
    It's simply due to an old animation on the object using the material color, and therefore forcing it.
    Anyway, thanks for your time, greatly appreciated!!!
     
  6. Wulirocks

    Wulirocks

    Joined:
    Mar 18, 2013
    Posts:
    63
    Yep... something was overriding it. Glad you fix it. You're welcome.