Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity adding component to another gameobject

//referencing a gameobject
public GameObject exampleObject;
//===============================================================>
private Rigidbody rb; //example of a component

public void Awake() {
	// adding a Rigidbody component to exampleObject
	rb = exampleObject.AddComponent<Rigidbody>();
  
	// referencing an existing Rigidbody component in exampleObject
	rb = exampleObject.GetComponent<Rigidbody>();
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to pause your game unity 
Csharp :: c# read text file to list string 
Csharp :: visual studio c# print to console 
Csharp :: c# create a text file 
Csharp :: loop over object properties c# 
Csharp :: c# combobox prevent typing 
Csharp :: c# async sleep 
Csharp :: unity reset rigidbody velocity 
Csharp :: make winforms full-screen c# 
Csharp :: how to stop window from terminating c# visual studio 
Csharp :: c# for each textbox lines 
Csharp :: unity get distance between two objects 
Csharp :: unity createassetmenu 
Csharp :: c# format string to date yyyymmdd 
Csharp :: stop program event in unity code 
Csharp :: base64 to image c# 
Csharp :: dotnet build to exe 
Csharp :: asp.net core get request ip address 
Csharp :: setup authorize in swagger .net core 
Csharp :: unity script detect if in prefab edition mode 
Csharp :: delete null elements array c# 
Csharp :: unity copy to clipboard 
Csharp :: how to play video in ui unity 
Csharp :: remove a specific line in richtextbox c# 
Csharp :: unity game sleep on hit 
Csharp :: windows form textbox numbers only 
Csharp :: Unity Rotate around the real center 
Csharp :: Unity Scene Load by Name 
Csharp :: stock span problem c# 
Csharp :: Unity C# make object face away 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =