ict.lixian.three/Assets/Scripts/UI/free/freeBtn1.cs

48 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using TMPro;
public class RobotBtn : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
{
public TextMeshProUGUI textMeshProUGUI;
private void Start()
{
textMeshProUGUI = GetComponentInChildren<TextMeshProUGUI>();
}
public void OnPointerClick(PointerEventData eventData)
{
g1.SetActive(false);
g2.SetActive(true);
textMeshProUGUI.color = Color.white;
}
public void OnPointerEnter(PointerEventData eventData)
{
textMeshProUGUI.color = Color.black;
}
public void OnPointerExit(PointerEventData eventData)
{
textMeshProUGUI.color = Color.white;
}
//[SerializeField] Button Btn;
[SerializeField] GameObject g1;
[SerializeField] GameObject g2;
// Start is called before the first frame update
//void Start()
//{
// Btn = transform.GetComponent<Button>();
// Btn.onClick.AddListener(() =>
// {
// g1.SetActive(false);
// g2.SetActive(true);
// });
//}
}