how to add a componet to a gameobject throgh code unity

Code Example - 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
                    
                
 

unity add component

                        
                                //Use the AddComponent<T>() Method to add a component to your gameobject
GameObject gameObject;

gameObject.AddComponent<BoxCollider>(); //Component has to be an actual Unity component
                            
                        
 

Related code examples