unity--鼠标放上显示物体信息和物体高光效果

unity--鼠标放上显示物体信息和物体高光效果_第1张图片

鼠标放在物体上显示信息代码

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);
        }
    }
}

物体高光效果使用的插件实现HighlightingSystem

unity--鼠标放上显示物体信息和物体高光效果_第2张图片

unity--鼠标放上显示物体信息和物体高光效果_第3张图片


demo案例

你可能感兴趣的:(unity--鼠标放上显示物体信息和物体高光效果)