Assigning GameObject the name of a stringa

can you change the name of GameObject from script? Not the tag orlayer but the name of the object you would see from the Hierarchy Menu.

3 Answers

3

See Object.name.

name = "Another name";

or

somethingElse.name = "Some other name";

name is a property of component, being that component inherits from Unity's Object, so you don't need the gameObject.

Yeah I was just out gathering more info about it when it struck me.

http://unity3d.com/support/documentation/ScriptReference/Object-name.html

Sure, just set it's name property:

GameObject.FindWithTag("MainCamera").name="MyMainMain";