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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Changing the transparency of an object. Switching alpha on shader/texture?

Discussion in 'General Graphics' started by codejoy, May 7, 2018.

  1. codejoy

    codejoy

    Joined:
    Aug 17, 2012
    Posts:
    204
    So I have this object in my scene that has a stone like material. I want to make it semi transparent. I can in the Standard shader, pick the transparent rendering mode and set the alpha in Albedo color to like 111. It looks great but the problem is:

    how can I set this in code? And also all things in a scene that share the same material have the same effect applied to them. Anyway to change this?
     
  2. codejoy

    codejoy

    Joined:
    Aug 17, 2012
    Posts:
    204
    Ahh I figured out how to do it:

    this.GetComponent<MeshRenderer>().material.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);