Question on Texture2D public variables

On Unity’s GUI Basics page it give this code:

/* Texture2D Content example */

var controlTexture : Texture2D;

function OnGUI () {
	GUI.Label (Rect (0,0,100,50), controlTexture);
}

My question is how to do I declare a Texture2D public variable for use in this script? I’m trying to get it to display an image.

I hope I explained it clearly, any help is appreciated

Update:
Perhaps the solution is similar to this?

controlTexture.LoadImage(imageTextAsset.bytes);

But now, how do I reference the image I want to be loaded?

The example is already declaring a Texture2D public variable, called “controlTexture”.

–Eric

I just want to know how to make it an image, so I can show an image in a GUI.Label

It is a variable for an image, and will do just that…I guess I’m not understanding what’s not working.

–Eric

I figured it out, thanks for helping though :stuck_out_tongue:

(I forgot to define it in the Unity editor)

You define the variable in script. You only assign it a value in the editor.