- 最后登录
- 2019-12-2
- 注册时间
- 2012-8-25
- 阅读权限
- 90
- 积分
- 34660
- 纳金币
- 38266
- 精华
- 111
|
鼠标图片icon(选中物体变换图片)C#代码- using UnityEngine;
-
- using System.Collections;
-
- public class mouseicon : MonoBehaviour {
-
- public Texture mouse_ico;
-
- public Texture mouse_sweep; //鼠标经过
-
- public Texture mouse_air; //鼠标点空气
-
- void Start () {
-
- Screen.showCursor=false;
-
- }
-
- // Update is called once per frame
-
- void Update ()
-
- {
-
- mouse_ico=mouse_air;
-
- Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
-
- RaycastHit hit;
-
- if (Physics.Raycast (ray,out hit, 100))
-
- {
-
- Debug.DrawLine (ray.origin, hit.point);
-
- if(hit.transform.tag==“renwu”)
-
- {
-
- mouse_ico=mouse_sweep;
-
- }
-
- else
-
- {
-
- mouse_ico=mouse_air;
-
- }
-
- }
-
- }
-
- void OnGUI()
-
- {
-
- Vector3 mouse_pos= Input.mousePosition;
-
- GUI.DrawTexture(new Rect(mouse_pos.x,Screen.height-mouse_pos.y,16,20),mouse_ico);
-
- }
-
- }
复制代码 |
|