- Home /
Beginner question about GUI scripting
Hi all. I'm trying to learn all about GUI and Javascript. In the GUI Basics documentation (http://unity3d.com/support/documentation/Components/gui-Basics.html) you're shown how to create buttons and place images on them using
/ Texture2D Content example /
var controlTexture : Texture2D;
function OnGUI () { GUI.Label (Rect (0,0,100,50), controlTexture); }
The example then shows a buttonw ith an image, but I still don't understand where the image comes from - having copied the code and played around with it, I can't replicate it!
Answer by aldonaletto · Dec 13, 2011 at 10:13 PM
Attach this script to any object, then click the object: in the Inspector you will see the script name and a field named Control Texture - click the small round "dot" button at the right and select the texture you want. The textures that will appear are those already imported to the project with Assets/Import New Asset menu option; if you want to create your own texture, do it with Photoshop or other image editor, save it and then import the texture to your project.
Answer by Eric5h5 · Dec 13, 2011 at 10:08 PM
It comes from you dragging it onto the Texture2D slot in the inspector.
Your answer
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
Move the text in a GUI Button/Box 1 Answer
Gui Text Script 4 Answers
GUI Button Disappearing 1 Answer
GUI.Box NullReferenceException 0 Answers