void OnDragEnd(dfControl source, dfDragEventArgs args) { ActionbarsDragCursor.Hide(); if (!this.isActionSlot) { return; } if (args.State == dfDragDropState.CancelledNoTarget) { Spell = ""; } refresh(); }
void OnDragStart(dfControl source, dfDragEventArgs args) { if (allowDrag(args)) { if (string.IsNullOrEmpty(Spell)) { // Indicates that the drag-and-drop operation cannot be performed args.State = dfDragDropState.Denied; } else { // Get the offset that will be used for the drag cursor var sprite = GetComponent <dfControl>().Find("Icon") as dfSprite; var ray = sprite.GetCamera().ScreenPointToRay(Input.mousePosition); var dragCursorOffset = Vector2.zero; if (!sprite.GetHitPosition(ray, out dragCursorOffset)) { return; } // Set the variables that will be used to render the drag cursor. // The UI library provides all of the drag and drop events necessary // but does not provide a default drag visualization and requires // that the application provide the visualization. We'll do that by // supplying a Texture2D that will be placed at the mouse location // in the OnGUI() method. ActionbarsDragCursor.Show(sprite, Input.mousePosition, dragCursorOffset); if (IsActionSlot) { // Visually indicate that they are *moving* the spell rather than // just dragging it into a slot sprite.SpriteName = ""; } // Indicate that the drag and drop operation can continue and set // the user-defined data that will be sent to potential drop targets args.State = dfDragDropState.Dragging; args.Data = this; } // Do not let the OnDragStart event "bubble up" to higher-level controls args.Use(); } }