コード例 #1
0
    /// <summary>
    /// On any item drag start need to disable all items raycast for correct drop operation
    /// </summary>
    /// <param name="item"> dragged item </param>
    private void OnAnyItemDragStart(DragAndDropItem item)
    {
        DragAndDropItem myItem = GetComponentInChildren <DragAndDropItem>(); // Get item from current cell

        if (myItem != null)
        {
            myItem.MakeRaycast(false);                                      // Disable item's raycast for correct drop handling
            if (myItem == item)                                             // If item dragged from this cell
            {
                // Check cell's type
                switch (cellType)
                {
                case CellType.DropOnly:
                    DragAndDropItem.icon.SetActive(false);                  // Item will not be dropped
                    break;

                case CellType.UnlimitedSource:
                    // Nothing to do
                    break;

                default:
                    item.MakeVisible(false);                                // Hide item in cell till dragging
                    SetBackgroundState(false);
                    break;
                }
            }
        }
    }
コード例 #2
0
 /// <summary>
 /// On any item drag start need to disable all items raycast for correct drop operation
 /// </summary>
 /// <param name="item"> dragged item </param>
 private void OnAnyItemDragStart(DragAndDropItem item)
 {
     DragAndDropItem myItem = GetComponentInChildren<DragAndDropItem>(); // Get item from current cell
     if (myItem != null)
     {
         myItem.MakeRaycast(false);                                      // Disable item's raycast for correct drop handling
         if (myItem == item)                                             // If item dragged from this cell
         {
             // Check cell's type
             switch (cellType)
             {
                 case CellType.DropOnly:
                     DragAndDropItem.icon.SetActive(false);              // Item will not be dropped
                     break;
                 case CellType.UnlimitedSource:
                     // Nothing to do
                     break;
                 default:
                     item.MakeVisible(false);                            // Hide item in cell till dragging
                     SetBackgroundState(false);
                     break;
             }
         }
     }
 }