コード例 #1
0
 /// <summary>
 /// This item is dragged
 /// </summary>
 public void OnDragStart()
 {
     dragedItem = null;
     sourceCell = null;
     if (dragEnabled == true)
     {
         sourceCell = GetComponentInParent<DragAndDropCell>();                   // Remember source cell
         dragedItem = this;                                                      // Set as dragged item
         MakeRaycast(false);                                                     // Disable raycast
         Canvas canvas = GetComponentInParent<Canvas>();                         // Get parent canvas
         if (canvas != null)
         {
             // Displya on top of all GUI (in current canvas)
             canvasTransform = canvas.transform;                                 // Remember parent canvas transform
             transform.SetParent(canvasTransform, true);                         // Set canvas as parent
             transform.SetAsLastSibling();                                       // Set as last child in canvas transform
         }
         if (OnItemDragStartEvent != null)
         {
             OnItemDragStartEvent();                                             // Notify all about item drag start
         }
         if (sourceCell != null)
         {
             sourceCell.ItemDragStart();                                         // Notify source cell about item drag start
         }
     }
 }