Draw GUITexture

Why I get errors with this code? cant get GUI.DrawTexture to use assigned to a variable texture.

'var SelHilight = Resources.Load("markRed");
			GUI.DrawTexture (new Rect(UnitScreenPos2.x,UnitScreenPos2.x, 32, 32), SelHilight);'

For example:
I have texture named MyTexture.tga in Resources folder
How to assign this texture to a PRIVATE variable and then use it in GUIDrawTexture ?
Please explain from A to Z mentioned above. Thanks guys!

I’m not if this is your script here or just selected lines. You should initialize ‘SelHilight’ in Start() or Awake(). GUI calls like GUI.DrawTexture() need to be executed in the OnGUI() function. Something like:

#pragma strict

var SelHilight : Texture;

function Start() {
	SelHilight = Resources.Load("markRed") as Texture;
}

function OnGUI() {
	GUI.DrawTexture (new Rect(UnitScreenPos2.x,UnitScreenPos2.x, 32, 32), SelHilight);
}