public gameobject unity

Code Example - public gameobject unity

                
                        INSTEAD OF WRITING PUBLIC LIKE THIS:-
public GameObject object;
YOU CAN WRITE SERIALIZEFIELD LIKE THIS:-
[SerializeField] GameObject object;
                    
                
 

public gameobject

                        
                                public GameObject myObject;
                            
                        
 

gameobject in unity csharp

                        
                                //define "myObject"
//(asign in in inspector)
public GameObject myObject;
//runs when you hit the play button
void Start()
{
  //change the name to "myObjectsNewName"
  myObject.name = "myObjectsNewName";
}
//Note for Unity and C#