Answers for "unity transparent object"

C#
1

unity transparent object

//For 2D sprites :
public GameObject myObject;

public void makeTransparent()
{
  var col = myObjetc.GetComponent<SpriteRenderer>().color;
  col.a = 0.5f; //Change the value of transparency here (with 0 = totally transparent and 1 = not transparent at all)
  myObjetc.GetComponent<SpriteRenderer>().color = col;
}

//For 3D gameObjects :
I think you have to use shaders there are a lot of youtube videos it is not only with a script
Posted by: Guest on April-18-2021
0

How to make game object transparent in unity

GameObject g;

// 50% Transparency.
g.renderer.material.color.a = 0.5f; // a is the alpha value.

 // 100% Transparency.
g.renderer.material.color.a = 1.0f;
Posted by: Guest on July-01-2021

C# Answers by Framework

Browse Popular Code Answers by Language