using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; using KTGMGemClient; public class ImageSkill : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler { bool isDraging; public bool IsDraging { get { return isDraging; } } public void OnBeginDrag(PointerEventData eventData) { isDraging = true; tmpImage.raycastTarget = false; GuideCtrl.Ins.BeginDrag11_1(); } 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 (skillRim != null) { //释放技能 Debug.Log("释放技能"); EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.SkillRelease); gameObject.SetActive(false); } else { rectTransform.anchoredPosition = pos; tmpImage.raycastTarget = true; //返回原位,提示开始推拽 GuideCtrl.Ins.EndDrag11_1(); } } GameObject skillRim; Image tmpImage; Vector2 pos; RectTransform rectTransform; // Start is called before the first frame update void Start() { //imageFire1 = transform.parent.Find("Image_Fire1").GetComponent(); tmpImage = GetComponent(); rectTransform = GetComponent(); pos = rectTransform.anchoredPosition; } public void SetTarget(GameObject target) { skillRim = target; } }