In the next release, can a method be exposed to allow a GameObject’s name to be changed via script?
We can set the name currently if we create the GameObject via script; however, if you need a tag associated with the GameObject, it appears we can only do that via a prefab. Of course, if you could also add a GameObject.Tag() method, we wouldn’t need to use prefabs. The prefab method is not preferred as it creates linked clones which is not the desired goal.
Would you benefit with adding these two methods to the scripting engine?
Actually, after tripping on this, I discovered that you change change the name of a GameObject via the method “myObjectRef.name” from this documentation page http://unity3d.com/support/documentation/ScriptReference/Object-name.html The GameObject inherits from Object, which has a name method. It would be great if the Object methods were add to the GameObject documentation page.
Unfortunately, the doc doesn’t show a proper example of use. Here is how to do it with C#
You don’t, just use gameObject.tag as I said. The example in the docs is quite proper; it simply applies to whatever gameobject the script is attached to.
Thanks a bunch for the quick response! I tried out the tag method and it worked great. Sure which it showed up in all my google searching. Most of the google post state it wasn’t possible.
I gladly retrack my post
Much appreciated!
p.s. the example could be better as I am using it in an editor window and not attached to a GameObject.
You can just look up GameObject in the docs, and all the variables/functions/etc. for it are listed right there. The posts you found saying it wasn’t possible were about creating tags from script, not assigning them to gameobjects.