using UnityEngine;
|
using UnityEngine.EventSystems;
|
using UnityEngine.UI;
|
using KTGMGemClient;
|
|
public class ImageFire2 : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler
|
{
|
bool isDraging;
|
public bool IsDraging
|
{
|
get
|
{
|
return isDraging;
|
}
|
}
|
public void OnBeginDrag(PointerEventData eventData)
|
{
|
isDraging = true;
|
tmpImage.raycastTarget = false;
|
GuideCtrl.Ins.BeginDrag();
|
}
|
|
Vector3 dragPos;
|
public void OnDrag(PointerEventData eventData)
|
{
|
RectTransformUtility.ScreenPointToWorldPointInRectangle(rectTransform, eventData.position, eventData.enterEventCamera, out dragPos);
|
//dragPos.z = 0;
|
rectTransform.position = dragPos;
|
}
|
|
public void OnEndDrag(PointerEventData eventData)
|
{
|
isDraging = false;
|
if (imageFire1 != null)
|
{
|
//合成宝石
|
Debug.Log("合成宝石");
|
imageFire1.Add();
|
gameObject.SetActive(false);
|
}
|
else
|
{
|
rectTransform.anchoredPosition = pos;
|
tmpImage.raycastTarget = true;
|
|
//返回原位,提示开始推拽
|
GuideCtrl.Ins.EndDrag();
|
}
|
|
}
|
|
ImageFire1 imageFire1;
|
Image tmpImage;
|
|
Vector2 pos;
|
|
RectTransform rectTransform;
|
// Start is called before the first frame update
|
void Start()
|
{
|
//imageFire1 = transform.parent.Find("Image_Fire1").GetComponent<ImageFire1>();
|
tmpImage = GetComponent<Image>();
|
rectTransform = GetComponent<RectTransform>();
|
pos = rectTransform.anchoredPosition;
|
}
|
|
public void SetTarget(ImageFire1 target)
|
{
|
imageFire1 = target;
|
}
|
|
}
|