- Home /
Change texture in runtime by type a word
Hello, i am just a beginer with Unity. I am working in "English for kid" project that require player input words to see things happen. For example: Player type "Tiger" in GUI, my game Object change texture to "Tiger". I know how to create a Gui, but i don't know how GUItext send command to game object (or any other method to do in my project). Thanks.
I guess you're using http://docs.unity3d.com/Documentation/ScriptReference/GUI.TextField.html for the textBox so http://docs.unity3d.com/Documentation/ScriptReference/GUI.Button.html should be good enough to handle the text.
Basically the first link states that if you use that code you're editing the "stringToEdit" string. So if you had a button you could use that to call some function that will handle the text input. In this case it would be a matter of checking if "stringToEdit" would be equal to "Tiger" and if it were you would change the texture (or do something else)
All that you need for that is something like..
if(textToEdit=="Tiger"){
//change your texture or do something else
}
I'm not sure if changing textures wold be the best thing. Perhaps switching between gameObjects that have a certain texture.
Hope this helps.