Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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
Comment

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;
Comment

PREVIOUS NEXT
Code Example
Csharp :: linux command line switch statement 
Csharp :: c# compress string 
Csharp :: c# regex get matched string 
Csharp :: get current playing animation of animator unity 
Csharp :: instantiate unity 
Csharp :: how to print hello world in c# 
Csharp :: c# string array contains 
Csharp :: convert string into double in c# 
Csharp :: unity vscode no autocomplete 
Csharp :: c# using file.io 
Csharp :: c# find element by condition 
Csharp :: c# environment variables 
Csharp :: write line to file c# 
Csharp :: c# combobox selected item 
Csharp :: c# print console 
Csharp :: get enum value from display name c# 
Csharp :: exit button unity code 
Csharp :: move files from one directory to another using c# 
Csharp :: c# use hashtable check if key exists 
Csharp :: create sequence of squares in c# 
Csharp :: c# byte 
Csharp :: list of list of string to list of string c# 
Csharp :: function on animation end unity 
Csharp :: binary search c# 
Csharp :: ef core set identity_insert off 
Csharp :: unity color by rgb 
Csharp :: c# int array 
Csharp :: c# sum of array elements# 
Csharp :: read file using c# 
Csharp :: get list length c# 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =