Swap Custom Cursor for Animated Movie Texture or Sprite Sheet?

I’m trying to make a cursor that is basically the same as the Kinect hand cursor… So when you hover over something, the circle animates around the hand and when it’s complete, a function will be called.

I have a sprite sheet prepared, and also a movie texture, but haven’t been able to get either to work. Maybe I’m using the wrong approach to begin with (Texture2D seems to cause problems in both cases).

Any clues for me? Here’s the code I have that works (just swaps one Texture2D for another). How would I make it show the animated cursor on hover?

var myCursor:Texture2D;
var myCursorHover:Texture2D;
var cursorSizeX: int = 64;  // set to width of your cursor texture
var cursorSizeY: int = 64;  // set to height of your cursor texture
private var cursor:Texture2D;

function Start(){
cursor = myCursor;
Screen.showCursor = false;
}


function OnGUI(){
    GUI.DrawTexture (Rect(Input.mousePosition.x-cursorSizeX + cursorSizeX/2, (Screen.height-Input.mousePosition.y)-cursorSizeY + cursorSizeY/2, cursorSizeX, cursorSizeY),cursor);
}

function cursorHover(){
	cursor = myCursorHover;
}

function cursorRestore(){
	cursor = myCursor;
}

I figured it out. Here is the working code, though I’m sure someone could write a more elegant version. I use a sprite texture that is 55 columns, one row.

var cursorOff:Texture2D;
var cursorOn:Texture2D;
var cursorSizeX: int = 64;  // set to width of your cursor texture
var cursorSizeY: int = 64;  // set to height of your cursor texture

private var hovering : boolean;
private var index : float;
private var v1 : float = 0.0;
private var v2 : float = 0.0;
private var v3 : float = 0.0181818; //width of each sprite by percent of total width
private var v4 : float = 1.0; //height
private var myRect : Rect;


function Start(){
	index = 0;
	hovering = false;
	Screen.showCursor = false;

}

function OnGUI(){

	if(hovering) {
		if(index <= 53){
			updateRect();
			GUI.DrawTextureWithTexCoords(Rect(Input.mousePosition.x-cursorSizeX + cursorSizeX/2, (Screen.height-Input.mousePosition.y)-cursorSizeY + cursorSizeY/2, cursorSizeX, cursorSizeY), cursorOn, myRect);
		}else{
			GUI.DrawTextureWithTexCoords(Rect(Input.mousePosition.x-cursorSizeX + cursorSizeX/2, (Screen.height-Input.mousePosition.y)-cursorSizeY + cursorSizeY/2, cursorSizeX, cursorSizeY),cursorOn, myRect);
		}
	}else {
		GUI.DrawTexture (Rect(Input.mousePosition.x-cursorSizeX + cursorSizeX/2, (Screen.height-Input.mousePosition.y)-cursorSizeY + cursorSizeY/2, cursorSizeX, cursorSizeY),cursorOff);
	}
}

function cursorHover(){
	hovering = true;
}

function cursorRestore(){
	index = 0;
	hovering = false;
}

function updateRect() {
	index += Time.deltaTime * 25;
	//print(index);
	v1 = (v3 * Mathf.Floor(index));
	myRect = Rect(v1,v2,v3,v4);
}