/// <summary>
 /// Put item into this cell.
 /// </summary>
 /// <param name="item">Item.</param>
 private void PlaceItem(DragAndDropItem item)
 {
     if (item != null)
     {
         DestroyItem();                                                                  // Remove current item from this cell
         myDadItem = null;
         DragAndDropCell cell = item.GetComponentInParent <DragAndDropCell>();
         if (cell != null)
         {
             if (cell.unlimitedSource == true)
             {
                 string itemName = item.name;
                 item      = Instantiate(item);                                                  // Clone item from source cell
                 item.name = itemName;
             }
         }
         item.transform.SetParent(transform, false);
         item.transform.localPosition = Vector3.zero;
         item.MakeRaycast(true);
         myDadItem = item;
     }
     UpdateBackgroundState();
 }
        /// <summary>
        /// Item is dropped in this cell
        /// </summary>
        /// <param name="data"></param>
        public void OnDrop(PointerEventData data)
        {
            if (DragAndDropItem.icon == null)
            {
                return;
            }
            DragAndDropItem item       = DragAndDropItem.draggedItem;
            DragAndDropCell sourceCell = DragAndDropItem.sourceCell;

            if (DragAndDropItem.icon.activeSelf == true)                                // If icon inactive do not need to drop item into cell
            {
                if ((item != null) && (sourceCell != this))
                {
                    if (!section.Equals(item.section))
                    {
                        return;
                    }

                    if ((!slot.Equals(item.slot)) && (!slot.Equals(DragAndDrop.Slot.Everything)))
                    {
                        return;
                    }

                    DropEventDescriptor desc = new DropEventDescriptor();
                    switch (cellType)                                                           // Check this cell's type
                    {
                    case CellType.Swap:                                                         // Item in destination cell can be swapped
                        UpdateMyItem();
                        switch (sourceCell.cellType)
                        {
                        case CellType.Swap:                                                                 // Item in source cell can be swapped
                            // Fill event descriptor
                            desc.item            = item;
                            desc.sourceCell      = sourceCell;
                            desc.destinationCell = this;
                            SendRequest(desc);                                                                  // Send drop request
                            StartCoroutine(NotifyOnDragEnd(desc));                                              // Send notification after drop will be finished
                            if (desc.permission == true)                                                        // If drop permitted by application
                            {
                                if (myDadItem != null)                                                          // If destination cell has item
                                {
                                    // Fill event descriptor
                                    DropEventDescriptor descAutoswap = new DropEventDescriptor();
                                    descAutoswap.item            = myDadItem;
                                    descAutoswap.sourceCell      = this;
                                    descAutoswap.destinationCell = sourceCell;
                                    SendRequest(descAutoswap);                                                                          // Send drop request
                                    StartCoroutine(NotifyOnDragEnd(descAutoswap));                                                      // Send notification after drop will be finished
                                    if (descAutoswap.permission == true)                                                                // If drop permitted by application
                                    {
                                        SwapItems(sourceCell, this);                                                                    // Swap items between cells
                                    }
                                    else
                                    {
                                        PlaceItem(item);                                                                    // Delete old item and place dropped item into this cell
                                    }
                                }
                                else
                                {
                                    PlaceItem(item);                                                                    // Place dropped item into this empty cell
                                }
                            }
                            break;

                        default:                                                                            // Item in source cell can not be swapped
                            // Fill event descriptor
                            desc.item            = item;
                            desc.sourceCell      = sourceCell;
                            desc.destinationCell = this;
                            SendRequest(desc);                                                                  // Send drop request
                            StartCoroutine(NotifyOnDragEnd(desc));                                              // Send notification after drop will be finished
                            if (desc.permission == true)                                                        // If drop permitted by application
                            {
                                PlaceItem(item);                                                                // Place dropped item into this cell
                            }
                            break;
                        }
                        break;

                    case CellType.DropOnly:                                                         // Item only can be dropped into destination cell
                        // Fill event descriptor
                        desc.item            = item;
                        desc.sourceCell      = sourceCell;
                        desc.destinationCell = this;
                        SendRequest(desc);                                                              // Send drop request
                        StartCoroutine(NotifyOnDragEnd(desc));                                          // Send notification after drop will be finished
                        if (desc.permission == true)                                                    // If drop permitted by application
                        {
                            PlaceItem(item);                                                            // Place dropped item in this cell
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            if (item != null)
            {
                if (item.GetComponentInParent <DragAndDropCell>() == null)                  // If item have no cell after drop
                {
                    Destroy(item.gameObject);                                               // Destroy it
                }
            }
            UpdateMyItem();
            UpdateBackgroundState();
            sourceCell.UpdateMyItem();
            sourceCell.UpdateBackgroundState();
        }