unity3d简单的图片代替鼠标

var Mid:Texture2D;

var Mouse:Texture2D;//鼠标图片

var mousePos = Vector2.zero;//鼠标的位置

private var angle:float;

function Update()
{

  mousePos = Input.mousePosition;//获取鼠标位置

  angle = 180 – Mathf.Atan2(mousePs.x – 250, Screen.height -mousePs.y – 250) * Mathf.Rad2Deg;//计算选择角度

}

 

 

function OnGUI () {
   Screen.showCursor = false;
   GUIUtility.RotateAroundPivot (angle, Vector2(250, 250));
   GUI.DrawTexture(Rect(200,200,100,100),Mid);
   GUIUtility.RotateAroundPivot (-angle, Vector2(250, 250));
   GUI.DrawTexture(Rect(mousePs.x,Screen.height -mousePs.y,25,25),mouse);

 

}

posted @ 2012-08-09 19:52  渡蓝  阅读(574)  评论(0)    收藏  举报