public void OnDrop(PointerEventData eventData)
    {
        if (eventData.pointerDrag == null)
        {
            return;
        }

        CrewUIIcon crewIcon = eventData.pointerDrag.GetComponent <CrewUIIcon>();

        if (crewIcon == null)
        {
            return;
        }

        CrewUISlot cur_slot        = slot;
        bool       cur_slot_vanish = cur_slot.vanish_empty;

        cur_slot.vanish_empty = false;

        CrewUISlot next_slot        = crewIcon.slot;
        bool       next_slot_vanish = next_slot.vanish_empty;

        next_slot.vanish_empty = false;

        LeaveSlot();
        crewIcon.InsertInto(cur_slot);
        InsertInto(next_slot);
        Snap();

        cur_slot.vanish_empty  = cur_slot_vanish;
        next_slot.vanish_empty = next_slot_vanish;
    }
 public void LeaveSlot()
 {
     if (slot != null)
     {
         slot.OnLeft(this);
         slot = null;
     }
 }
    public CrewUIIcon GenIcon(CrewUISlot slot)
    {
        CrewUIIcon crewIcon = Instantiate(Game.inst.crewIconUI_prefab, slot.gameObject.transform).GetComponent <CrewUIIcon>();

        crewIcon.member = this;
        crewIcon.SetPortraitName(portaitName);
        return(crewIcon);
    }
 public void UpdateCrewSlots()
 {
     availableCrew = new List <CrewUISlot>();
     for (int i = 0; i < crewSeats; i++)
     {
         CrewUISlot crewSlot = Instantiate(Game.inst.crewSlotUI_prefab, transform).GetComponent <CrewUISlot>();
         availableCrew.Add(crewSlot);
     }
 }
    public void InsertInto(CrewUISlot new_slot)
    {
        if (slot != null)
        {
            slot.OnLeft(this);
        }

        slot = new_slot;
        slot.OnInserted(this);
    }
    void OnDestroy()
    {
        if (slot != null)
        {
            slot.filled = null;
        }

        canvas        = null;
        image         = null;
        canvasGroup   = null;
        rectTransform = null;

        slot = null;
    }
    public void InsertNew(CrewUIIcon crewIcon)
    {
        GameObject crewSlotObj = Instantiate(Game.inst.crewSlotUI_prefab, gameObject.transform);

        CrewUISlot crewSlot = crewSlotObj.GetComponent <CrewUISlot>();

        if (slotsVanish)
        {
            crewSlot.vanish_empty = slotsVanish;
        }

        crewIcon.InsertInto(crewSlot);
        crewIcon.Snap();
    }