78 lines
1.8 KiB
C#
78 lines
1.8 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine.EventSystems;
|
|||
|
|
|||
|
public class GuideStepClickItem : MonoBehaviour, IPointerClickHandler
|
|||
|
{
|
|||
|
|
|||
|
public delegate void ItemClick(object initInfo);
|
|||
|
|
|||
|
public ItemClick _ClickEvent;
|
|||
|
|
|||
|
public RectTransform _OrgGOTrans;
|
|||
|
public RectTransform _SelfGOTrans;
|
|||
|
|
|||
|
public List<Image> _OrgImage = new List<Image>();
|
|||
|
public List<Image> _SelfImage = new List<Image>();
|
|||
|
|
|||
|
public List<Text> _OrgText = new List<Text>();
|
|||
|
public List<Text> _SelfText = new List<Text>();
|
|||
|
|
|||
|
public bool _IsClickBehind = true;
|
|||
|
|
|||
|
void Update()
|
|||
|
{
|
|||
|
if (_OrgGOTrans != null && _SelfGOTrans != null)
|
|||
|
{
|
|||
|
_SelfGOTrans.position = _OrgGOTrans.position;
|
|||
|
_SelfGOTrans.sizeDelta = _OrgGOTrans.sizeDelta;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
if (_OrgImage.Count > 0 && _OrgImage.Count == _SelfImage.Count)
|
|||
|
{
|
|||
|
for (int i = 0; i < _OrgImage.Count; ++i)
|
|||
|
{
|
|||
|
if (_OrgImage[i].sprite != null)
|
|||
|
{
|
|||
|
_SelfImage[i].sprite = _OrgImage[i].sprite;
|
|||
|
_SelfImage[i].enabled = true;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
for (int i = 0; i < _OrgText.Count; ++i)
|
|||
|
{
|
|||
|
if (_OrgText[i].text != _SelfText[i].text)
|
|||
|
{
|
|||
|
_SelfText[i].text = _OrgText[i].text;
|
|||
|
_SelfText[i].enabled = true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OnPointerClick(PointerEventData eventData)
|
|||
|
{
|
|||
|
OnItemClick();
|
|||
|
|
|||
|
if (_IsClickBehind)
|
|||
|
{
|
|||
|
UIManager.Instance().RayCastBebind(eventData);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public virtual void OnItemClick()
|
|||
|
{
|
|||
|
if (_ClickEvent != null)
|
|||
|
{
|
|||
|
_ClickEvent(this);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|