//设置技能 public void SetSkill(SkillDrag sd) { if (existSkill) { //交换图标 Sprite tempSprite = skillIcon.sprite; skillIcon.sprite = sd.skillIcon.sprite; sd.skillIcon.sprite = tempSprite; //交换技能 skill tempSkill = this.thisSkill; this.thisSkill = sd.thisSkill; sd.thisSkill = tempSkill; } else//如果该图标为空 { SetNotEmpty(sd.skillIcon.sprite, sd.thisSkill);//设为非空 thisSkill = sd.thisSkill; skillIcon.sprite = sd.skillIcon.sprite;//设置图标 //sd.skillIcon.color = new Color(sd.skillIcon.color.r, sd.skillIcon.color.g, sd.skillIcon.color.b, 0); //sd.thisSkill = null; sd.SetEmpty();//将对方置空 } //如果拖到下方区域,重新整理 if ((!isActive && !sd.existSkill) || (!sd.isActive && !sd.existSkill)) { skillsSetting.SortInactiveSkills(); } }
public void OnDrag(PointerEventData eventData) { if (longPressed) { Vector2 inputPos = Input.mousePosition; Vector2 transedPos = new Vector2(inputPos.x * wr, inputPos.y * hr); SkillDrag sdrag = CheckUIRaycastObjects(eventData).GetComponent <SkillDrag>();//获取射线得到的目标 //SkillSetting sSetting = rayed.GetComponent<SkillSetting>(); //if(rayed.GetComponent<SkillSetting>()) sSetting = rayed.GetComponent<SkillSetting>(); if (null != sdrag) { thisRect.anchoredPosition = sdrag.normalPos; } else { thisRect.anchoredPosition = transedPos; } } }
public void OnPointerUp(PointerEventData eventData) { if (!existSkill) { return; } pressed = false; thisImg.color = normalColor; if (longPressed) { longPressed = false; SkillDrag sdrag = CheckUIRaycastObjects(eventData).GetComponent <SkillDrag>();//获取射线得到的目标 if (null != sdrag) { sdrag.SetSkill(this); } thisRect.anchoredPosition = normalPos; } thisImg.raycastTarget = true;//启用射线检测 //设定父物体 StopAllCoroutines(); StartCoroutine(Release()); }