Rotate GUI custom mouse cursor?

This is my Script:

var yourCursor : Texture2D;  // Your cursor texture
var cursorSizeX : int = 16;  // Your cursor size x
var cursorSizeY : int = 16;  // Your cursor size y
 
function Start()
{
    Screen.showCursor = false;
}
 
function OnGUI()
{
    GUI.DrawTexture (Rect(Event.current.mousePosition.x-cursorSizeX/3, Event.current.mousePosition.y-cursorSizeY/3.5, cursorSizeX, cursorSizeY), yourCursor);
}

19607-mousecursor_all2.png

I want mouse cursor rotate itself always when I Play the game.
Could anyone help me :frowning:

Thanks for your kind!

GUI elements can be rotated using GUIUtility.RotateAroundPivot(). Here is some example code. Note I’ve used a more traditional calculation for x and y. I’m assuming your calculations were so that the cursor position was offset from the middle of the texture. You’ll have to adapt the ‘pivot’ calculation for whatever cursor calculation you use.

var yourCursor : Texture2D;  // Your cursor texture
var cursorSizeX : int = 16;  // Your cursor size x
var cursorSizeY : int = 16;  // Your cursor size y

var speed = 90.0;
private var angle = 0.0;
 
function Start()
{
    Screen.showCursor = false;
}

function Update() {
    angle += Time.deltaTime * speed;
    angle = angle % 360.0;
}
 
function OnGUI()
{
	var matx = GUI.matrix;
	var x = Event.current.mousePosition.x-cursorSizeX/2.0;
	var y = Event.current.mousePosition.y-cursorSizeY/2.0;
	var pivot = Vector2(x + cursorSizeX / 2.0,y + cursorSizeY / 2.0);
	GUIUtility.RotateAroundPivot(angle, pivot);
    GUI.DrawTexture (Rect(x, y, cursorSizeX, cursorSizeY), yourCursor);
    GUI.matrix = matx;
}