鼠标样式改变 隐藏鼠标在鼠标位置绘制图片,当鼠标经过时改变样式
2015-09-02 12:13
609 查看
//隐藏鼠标图标
//Screen.showCursor=false;
void OnGUI(){
//Vector2 mouse_pos=Input.mousePosition;
//GUI.DrawTexture( new Rect(mouse_pos.x,Screen.height-mouse_pos.y,26,30),mouse_pic);
————————————————————
using UnityEngine;
using System.Collections;
public class ank : MonoBehaviour {
public GUITexture anz_bl;
//引用鼠标图片 图片必须设置成Cursor 光标格式,当鼠标经过时改变样式
public Texture2D cursorTexture;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnMouseDown(){
if (GetComponent<ank> ().enabled == true) {
//重新计时
anz_bl.transform.GetComponent<move_z> ().Start ();
//可以作其他事情。。。Dosomething()..
//设置游戏管理器中an01=true
if(this.gameObject.name=="an01k"){
GameManager.Instance.an01=true;}
if(this.gameObject.name=="an02k"){
GameManager.Instance.an02=true;}
}
}
void OnMouseOver(){
//改变鼠标样式
Cursor.SetCursor(cursorTexture,Vector2.zero,CursorMode.Auto);
}
void OnMouseExit(){
//恢复鼠标图标
Cursor.SetCursor(null, Vector2.zero,CursorMode.Auto);
}
}
//Screen.showCursor=false;
void OnGUI(){
//Vector2 mouse_pos=Input.mousePosition;
//GUI.DrawTexture( new Rect(mouse_pos.x,Screen.height-mouse_pos.y,26,30),mouse_pic);
————————————————————
using UnityEngine;
using System.Collections;
public class ank : MonoBehaviour {
public GUITexture anz_bl;
//引用鼠标图片 图片必须设置成Cursor 光标格式,当鼠标经过时改变样式
public Texture2D cursorTexture;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnMouseDown(){
if (GetComponent<ank> ().enabled == true) {
//重新计时
anz_bl.transform.GetComponent<move_z> ().Start ();
//可以作其他事情。。。Dosomething()..
//设置游戏管理器中an01=true
if(this.gameObject.name=="an01k"){
GameManager.Instance.an01=true;}
if(this.gameObject.name=="an02k"){
GameManager.Instance.an02=true;}
}
}
void OnMouseOver(){
//改变鼠标样式
Cursor.SetCursor(cursorTexture,Vector2.zero,CursorMode.Auto);
}
void OnMouseExit(){
//恢复鼠标图标
Cursor.SetCursor(null, Vector2.zero,CursorMode.Auto);
}
}
相关文章推荐
- Kinect结合Unity3D引擎开发体感游戏(一)
- Unity3D中脚本的执行顺序和编译顺序
- Unity3D动态对象优化代码分享
- unity3d发布apk在android虚拟机中运行的详细步骤(unity3d导出android apk)
- Unity3D游戏引擎实现在Android中打开WebView的实例
- unity3d调用手机或电脑摄像头
- 分享一个开源的网络游戏服务器架构—HouHai
- Unity3D插件详细评测及教学下载
- Unity3D上路_01-2D太空射击游戏
- Unity3D上路_02-第一视角射击游戏
- Unity3D上路_03-塔防游戏
- Unity3D上路_04-基础资源介绍
- Unity3D上路_05-网络相关
- Unity3d TransformPoint 函数研究
- Unity3d 动态加载fbx模型文件
- unity3d地形系统总结