- Home /
The question is answered, right answer was accepted
Convert GameObject to String?
Noob here just simple question how do I convert gameobject to string variable? Thanks in advance :D
Answer by save · Jan 02, 2012 at 02:56 PM
Do you mean a name of a GameObject? Cause then it's:
var goName : String = gameObject.name;
If you mean something else, remember that you have the ToString() function.
Answer by rabbitfang · Jan 02, 2012 at 04:46 PM
Based on your question, it would appear that you have little to no programming experience. In order to convert your object to a string (through the most common method), you need to implement the ToString()
function in a script attached to your game object. Of course, this requires you to call that function on the script itself, as calling GameObject.ToString()
won't call your implementation.
Of course, I have no idea what you want specifically to be in that string. If you only want the object's name, save had the right idea: use gameObject.name
.
Follow this Question
Related Questions
Converting String to a Game Object 1 Answer
Convert game object to string? 1 Answer
Convert String to GameObject[] type Array 2 Answers
iOS Not Converting String to Integer 0 Answers
Array - Convert Object into Int 5 Answers