unity add component to gameobject in script code example
Example 1: Add component object to gameobject unity
//to add a new ridgidbody
gameobject.AddComponent<Rigidbody>();
//to add a new meshCollider
gameobject.AddComponent<MeshCollider>();
//Original answer by MakerBenjammin6, cleanup by me.
Example 2: On add component unity
void Reset()
{
//Your code here
}
Example 3: how to add a componet to a gameobject throgh code unity
//This uses C# and unity
//to add a ridgidbody
gameobject.addComponet<ridgidbody>();
//to add a meshCollider
gameobject.addComponet<MeshCollider>();
//check out my profile