How to make the image more transparent (alpha)? Interested in two approaches and the script in the Unity environment.

  • one
    What component is used? There is a regulation of transparency in color - Valera Kvip
  • I created Sprite Renderer, where I add a picture through Sprite. By the way, speaking, the picture is a circle (o) of the color of aquamarine, so if there is another way of color, then the picture can be replaced with the color will be. - J. Defenses

2 answers 2

Through the editor:

In the Sprite Renderer component, click on Color . Then use the slider to change the parameter A.

enter image description here

Through the script:

var sr = GetComponent<SpriteRenderer>(); sr.color = new Color(0, 0, 0, 0.5f);// (r,g,b,a); последний параметр прозрачность. От 0 до 1. 

https://docs.unity3d.com/ScriptReference/Color-ctor.html

     gameObject.GetComponent<SpriteRenderer>().color = new Color(1f, 1f, 1f, 0.5f); 

    Where 0.5f is set alpha channel color. In this case, 0.5 means 50% transparency. 1f - not transparent (0%). 0f is completely transparent (100%).