Draggable Window UGUI

🪟 DraggableWindowUGUI Class

A draggable window for uGUI support.

Namespace: Esper.Inventool.UI.UGUI Access: public Type: class Inherits: CrossInputSupportedWindowUGUI, IPointerDownHandler, IDragHandler, IBeginDragHandler, IEndDragHandler


📦 Fields

Access
Field
Type
Description

public

activeSortingOrder

int

Sorting order when the window becomes active.

public

inactiveSortingOrder

int

Sorting order when the window becomes inactive.

protected

startingMousePosition

Vector2

Starting mouse position.

protected

startingWindowPosition

Vector2

Starting window position.

protected

pointerDown

bool

True while the pointer button is held down on the element.

protected

firstOpen

bool

True if the window is opening for the first time.

public static

windows

List<DraggableWindowUGUI>

List of draggable windows in the scene.

public static

active

DraggableWindowUGUI

The active draggable window.


📢 Events

Access
Event
Type
Description

public static

onDragStarted

UnityEvent

Invoked when dragging begins on any window.

public static

onDrag

UnityEvent

Invoked when any window is moved through dragging.

public static

onStopDrag

UnityEvent

Invoked when dragging stops on any window.


🧰 Methods

Access
Method
Returns
Description

protected override

Awake()

void

Initializes base and registers this window in the global windows list.

private

OnDestroy()

void

Removes this window from the global windows list.

public

SetNextAsActive()

void

Sets the next open window as active, cycling through opened windows.

public virtual

Open()

void

Opens the window (shows content) and marks first open as false.

public virtual

Close()

void

Closes the window, updates active window, closes related UI, invokes onClosed.

public

SetAsActive()

void

Sets this window as active and updates canvas sorting order.

public

SetAsInactive()

void

Sets this window as inactive and updates canvas sorting order.

public

OnPointerDown(PointerEventData eventData)

void

Sets this window as active when clicked.

public

OnBeginDrag(PointerEventData eventData)

void

Begins drag if left button and no DragPrevention parent blocks it.

public

OnDrag(PointerEventData eventData)

void

Moves the window with the mouse while dragging, invokes onDrag.

public

OnEndDrag(PointerEventData eventData)

void

Ends drag on left button release, invokes onStopDrag.

Active Window

The active draggable window is the one that was last interacted with. This happens automatically. You can access the active draggable window with DraggableWindowUGUI.active.

You can set a draggable window as the active one with the SetAsActive method. Use SetAsInactive to have the opposite effect.

myDraggableWindow.SetAsActive();

To set the next one as active, use SetNextAsActive.

myDraggableWindow.SetNextAsActive();

Last updated