39 lines
976 B
C#
39 lines
976 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
|
|
// 掛在開始按鈕上 : 按鈕反灰時,滑鼠移上去會顯示提示
|
|
public class StartButtonHint : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
|
|
{
|
|
[Header("UI 參照")]
|
|
[Tooltip("開始 Button")]
|
|
public Button targetButton;
|
|
|
|
[Tooltip("提示物件 (例如寫著「請閱讀資訊欄並勾選同意書」的 Text 或 Panel)")]
|
|
public GameObject hintObject;
|
|
|
|
void Start()
|
|
{
|
|
if (hintObject != null)
|
|
{
|
|
hintObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
if (hintObject != null && targetButton != null && !targetButton.interactable)
|
|
{
|
|
hintObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
if (hintObject != null)
|
|
{
|
|
hintObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|