赞
踩
鼠标放在物体上显示信息代码
- using UnityEngine;
- using System.Collections;
-
- public class info : MonoBehaviour {
-
- bool isShowInfo;
- public GUIStyle _GUIStyle;
- public float Offset = 15;
- public string Info = "名字";
- // Use this for initialization
- void Start () {
- isShowInfo = false;
-
- }
- void OnMouseEnter()
- {
- isShowInfo = true;
- // print("onmouseenter");
- }
- void OnMouseExit()
- {
- isShowInfo = false;
- // print("onmouseexit");
- }
-
- // Update is called once per frame
- void Update () {
-
- }
- void OnGUI()
- {
-
-
- if (isShowInfo)
- {
- print("123");
- GUI.Label(new Rect(Input.mousePosition.x + Offset, Screen.height - Input.mousePosition.y, 100, 100), Info, _GUIStyle);
- }
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。