Exemplo n.º 1
0
    // Token: 0x06000934 RID: 2356 RVA: 0x0003A754 File Offset: 0x00038954
    public void DrawSlot <T>(Rect rect, T item, Action <int, T> onDropAction = null, Color?color = null, bool isItemList = false) where T : IDragSlot
    {
        int controlID = GUIUtility.GetControlID(DragAndDrop._itemSlotButtonHash, FocusType.Native);

        if ((ApplicationDataManager.Channel == ChannelType.Android || ApplicationDataManager.Channel == ChannelType.IPad || ApplicationDataManager.Channel == ChannelType.IPhone) && Event.current.GetTypeForControl(controlID) == EventType.MouseDown && isItemList)
        {
            rect.width = 50f;
        }
        switch (Event.current.GetTypeForControl(controlID))
        {
        case EventType.MouseDown:
            if (Event.current.type != EventType.Used && rect.Contains(Event.current.mousePosition))
            {
                GUIUtility.hotControl = controlID;
                Event.current.Use();
            }
            break;

        case EventType.MouseUp:
            this.MouseUp <T>(rect, controlID, item.Id, onDropAction);
            break;

        case EventType.MouseDrag:
            if (GUIUtility.hotControl == controlID)
            {
                Vector2 vector = GUIUtility.GUIToScreenPoint(new Vector2(rect.x, rect.y));
                this._draggedControlRect = new Rect(vector.x, vector.y, rect.width, rect.height);
                this._dragBegin          = true;
                this.DraggedItem         = item;
                this.CurrentId           = GUIUtility.hotControl;
                GUIUtility.hotControl    = 0;
                Event.current.Use();
            }
            break;

        case EventType.Repaint:
            if (color != null)
            {
                GUI.color = color.Value;
                BlueStonez.loadoutdropslot_highlight.Draw(rect, GUIContent.none, controlID);
                GUI.color = Color.white;
            }
            break;
        }
    }
Exemplo n.º 2
0
 // Token: 0x06000932 RID: 2354 RVA: 0x0003A59C File Offset: 0x0003879C
 private void OnGui()
 {
     if (this._releaseDragItem)
     {
         this._releaseDragItem = false;
         this.CurrentId        = 0;
         this.DraggedItem      = null;
     }
     if (Event.current.type == EventType.MouseUp)
     {
         this._releaseDragItem = true;
     }
     if (this.IsDragging)
     {
         if (this._dragBegin)
         {
             this._dragBegin = false;
             if (this.OnDragBegin != null)
             {
                 this.OnDragBegin(this.DraggedItem);
             }
             UnityRuntime.StartRoutine(this.StartDragZoom(0f, 1f, 1.25f, 0.1f, 0.8f));
         }
         else
         {
             if (!this._isZooming)
             {
                 this._dragScalePivot = GUIUtility.ScreenToGUIPoint(Event.current.mousePosition);
             }
             GUIUtility.ScaleAroundPivot(new Vector2(this._zoomMultiplier, this._zoomMultiplier), this._dragScalePivot);
             GUI.backgroundColor = new Color(1f, 1f, 1f, this._alphaValue);
             GUI.matrix          = Matrix4x4.identity;
             this.DraggedItem.Item.DrawIcon(new Rect(this._dragScalePivot.x - 24f, this._dragScalePivot.y - 24f, 48f, 48f));
         }
     }
 }