//用指定图片替换鼠标指针
public var mouse:Texture2D;
static var guiDepth : int = 0;
function Update()
{
}
function OnGUI()
{
GUI.Window(1,new Rect(200,10,200,50),test,"123");
if(new Rect(200,Screen.height-10-40,50,40).Contains(Input.mousePosition)
|| new Rect(200+60,Screen.height-10-40,50,40).Contains(Input.mousePosition))
{
Screen.showCursor=false;//隐藏鼠标指针
var msPos=Input.mousePosition;//鼠标的位置
GUI.DrawTexture(Rect(msPos.x,Screen.height-msPos.y,20,20),mouse); //在鼠标的位置DrawTexture
GUI.depth = guiDepth; //设置GUI的深度,控制替换的图片在按钮的上面显示
}else
{
Screen.showCursor=true;//显示鼠标指针
}
}
function test()
{
GUI.Button(new Rect(0,0,50,40),"111");
GUI.Button(new Rect(60,0,50,40),"222");
}
注意:鼠标的(0,0,0)在左下角(Input.mousePosition);Screen的(0,0)在左上角