unity--滑鼠放上顯示物體資訊和物體高光效果
阿新 • • 發佈:2018-12-30
滑鼠放在物體上顯示資訊程式碼
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