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

how to access material in element 2

Discussion in 'Scripting' started by pat_sommer, May 30, 2011.

  1. pat_sommer

    pat_sommer

    Joined:
    Jun 28, 2010
    Posts:
    586
    hey everyone, how do i go about accessing the material in element 1 or any other material of a multi material object? id like to change the color via script
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Code (csharp):
    1. var materials = renderer.materials;
    2. materials[1].color = Color.red;
    3. renderer.materials = materials;
    --Eric