unity sprite with transparent background code example

Example 1: unity set sprite transparency

// You can set the transparency together with the color:
SpriteRenderer.color = new Color(1f,1f,1f,1f);

Example 2: unity transparent sprite

If your PNG is already supposed to be transparent, but it shows a white background in the inspector, Click on it then under the inspector click on the checkbox "Alpha Is Transparency". 
That will set the white background transparent.

Tags:

Misc Example