ict.lixian.three/Assets/Scripts/UI/changjingBtn.cs

84 lines
2.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class changjingBtn : MonoBehaviour, IPointerDownHandler, IPointerEnterHandler, IPointerExitHandler
{
[SerializeField] new Image image;
[SerializeField] TextMeshProUGUI text;
[SerializeField] TextMeshProUGUI text2;
[SerializeField] Image image2;
[SerializeField]bool isok = false;
[SerializeField]int sum = 1;
[SerializeField] free free;
public void OnPointerDown(PointerEventData eventData)
{
Debug.Log("111");
text.color = Color.black;
text2.color = Color.black;
image.gameObject.SetActive(true);
if (sum%2!=0)
{
isok = true;
}
else
{
isok = false;
}
sum++;
}
public void OnPointerEnter(PointerEventData eventData)
{
Debug.Log("1");
text.color = Color.black;
text2.color = Color.black;
image.gameObject.SetActive(true);
}
public void OnPointerExit(PointerEventData eventData)
{
if (isok)
{
text.color = Color.black;
text2.color = Color.black;
image.gameObject.SetActive(true);
Debug.Log("2");
}
if (image2 != null && isok)
{
image2.raycastTarget = true;
return;
}
else
{
if (image2)
{
image2.raycastTarget = false;
}
text.color = Color.white;
text2.color = Color.white;
image.gameObject.SetActive(false);
Debug.Log("2");
}
isok = false;
}
public void hide()
{
text.color = Color.white;
text2.color = Color.white;
image.gameObject.SetActive(false);
if (image2)
{
image2.raycastTarget = false;
free.hide();
free.Add();
}
isok = false;
}
}