예제 #1
0
 public void OnDrop(PointerEventData eventData)
 {
     draggedUnit = eventData.pointerDrag.GetComponent <DragAndDrop>();
     if (eventData.pointerDrag != null && activeUnit == null)
     {
         draggedUnit.SetParentToNull();
         draggedUnit.BlockRaycasts(true);
         eventData.pointerDrag.GetComponent <RectTransform>().anchoredPosition = GetComponent <RectTransform>().anchoredPosition;
         print("Changing active unit!");
         activeUnit = eventData.pointerDrag.GetComponent <Unit>();
         draggedUnit.SetActive(true);
         draggedUnit.SetParent(this);
     }
 }
예제 #2
0
    public void Awake()
    {
        if (active == null)
        {
            activeUnit  = null;
            draggedUnit = null;
        }
        else
        {
            activeUnit  = active.GetComponent <Unit>();
            draggedUnit = active.GetComponent <DragAndDrop>();
            draggedUnit.SetParent(this);
        }

        name_text = GetComponentInChildren <TextMeshProUGUI>();
    }