Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

MeshRenderer override materials at run-time.

Discussion in 'Unity 5 Pre-order Beta' started by GameArt, Jan 6, 2015.

  1. GameArt

    GameArt

    Joined:
    Feb 24, 2013
    Posts:
    86
    I'm having an issue with over-ridding materials at run-time in 5r18.

    Unable to override materials using .materials[] or .shaderMaterials[].
    When I try to override a material in slot 0/1/2/3... nothing happens.
    mesh_renderer.materials[ slot ] = the runtime material;
    or
    mesh_renderer.sharedMaterials[ slot ] = the runtime material;
    I've tried executing this in an attached component in Awake, Start and the first call to Update- none actually change the material on the object.
    Using mesh_renderer.material = the runtime material; works correctly.

    This code was previously valid in Unity 4, and I don't see any obvious work around's in MeshRenderer.
     
    Last edited: Jan 6, 2015
  2. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Please file a bug report. Thanks!