36 lines
1007 B
C#
36 lines
1007 B
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.EventSystems;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
|
||
|
|
// 点击图片时图片样式发生改变
|
||
|
|
public class ClickImageUIChange : MonoBehaviour,IPointerClickHandler
|
||
|
|
{
|
||
|
|
private Image image; // 图片组件
|
||
|
|
private bool isClick = false; // 是否点击
|
||
|
|
|
||
|
|
public Color normalColor; // 正常状态颜色
|
||
|
|
public Color clickColor = new Color(1f,1f,1f,0.5f); // 点击状态颜色
|
||
|
|
|
||
|
|
// Start is called before the first frame update
|
||
|
|
void Start()
|
||
|
|
{
|
||
|
|
image = GetComponent<Image>();
|
||
|
|
normalColor = image.color;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
public void OnPointerClick(PointerEventData eventData)
|
||
|
|
{
|
||
|
|
isClick = ! isClick;
|
||
|
|
image.color = isClick ? clickColor : normalColor;
|
||
|
|
|
||
|
|
EnterImageUIChange enterImageUIChange = gameObject.GetComponent<EnterImageUIChange>();
|
||
|
|
if (enterImageUIChange!=null)
|
||
|
|
{
|
||
|
|
enterImageUIChange.exitColor = image.color;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|