Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
UIDragPanel Class Reference
Inheritance diagram for UIDragPanel:
IChangeResolution

Public Member Functions

void SetTarget (RectTransform r)
 
void OnChangeResolution ()
 
void OnPointerDown (PointerEventData data)
 
void OnPointerUp (PointerEventData data)
 
void OnInitializePotentialDrag (PointerEventData ped)
 
void OnDrag (PointerEventData data)
 
void OnChangeResolution ()
 

Public Attributes

RectTransform target
 
RectTransform bound
 
RectTransform container
 
bool axisY = true
 
bool axisX = true
 
bool enable = true
 
bool autoAnchor
 
bool clamp = true
 
Action onDrag
 

Static Public Attributes

static bool dragging
 

Private Member Functions

void Awake ()
 
void ClampToWindow ()
 

Private Attributes

Vector2 originalLocalPointerPosition
 
Vector3 originalPanelLocalPosition
 

Detailed Description

Definition at line 5 of file UIDragPanel.cs.

Member Function Documentation

◆ Awake()

void UIDragPanel.Awake ( )
inlineprivate

Definition at line 31 of file UIDragPanel.cs.

32 {
33 if (target == null)
34 {
35 target = base.transform.parent as RectTransform;
36 }
37 if (bound == null)
38 {
39 bound = target;
40 }
41 }
RectTransform bound
Definition: UIDragPanel.cs:15
RectTransform target
Definition: UIDragPanel.cs:13

References bound, and target.

◆ ClampToWindow()

void UIDragPanel.ClampToWindow ( )
inlineprivate

Definition at line 104 of file UIDragPanel.cs.

105 {
106 Vector3 localPosition = target.localPosition;
107 Vector3 vector = container.rect.min - bound.rect.min;
108 Vector3 vector2 = container.rect.max - bound.rect.max;
109 if (axisX)
110 {
111 localPosition.x = (int)Mathf.Clamp(localPosition.x, vector.x - 20f, vector2.x + 20f);
112 }
113 if (axisY)
114 {
115 localPosition.y = (int)Mathf.Clamp(localPosition.y, vector.y - 20f, vector2.y + 20f);
116 }
117 target.localPosition = localPosition;
118 }

References axisX, axisY, bound, and target.

Referenced by OnDrag().

◆ OnChangeResolution()

void UIDragPanel.OnChangeResolution ( )
inline

Implements IChangeResolution.

Definition at line 49 of file UIDragPanel.cs.

50 {
51 }

◆ OnDrag()

void UIDragPanel.OnDrag ( PointerEventData  data)
inline

Definition at line 84 of file UIDragPanel.cs.

85 {
86 if (enable && data.button == PointerEventData.InputButton.Left && !(target == null) && !(container == null))
87 {
88 if (RectTransformUtility.ScreenPointToLocalPointInRectangle(container, data.position, data.pressEventCamera, out var localPoint))
89 {
90 Vector3 vector = localPoint - originalLocalPointerPosition;
91 target.localPosition = originalPanelLocalPosition + vector;
92 }
93 if (clamp)
94 {
96 }
97 if (onDrag != null)
98 {
99 onDrag();
100 }
101 }
102 }
void ClampToWindow()
Definition: UIDragPanel.cs:104
Action onDrag
Definition: UIDragPanel.cs:29
Vector3 originalPanelLocalPosition
Definition: UIDragPanel.cs:11
RectTransform container
Definition: UIDragPanel.cs:17
Vector2 originalLocalPointerPosition
Definition: UIDragPanel.cs:9

References clamp, ClampToWindow(), container, enable, onDrag, originalLocalPointerPosition, originalPanelLocalPosition, and target.

◆ OnInitializePotentialDrag()

void UIDragPanel.OnInitializePotentialDrag ( PointerEventData  ped)
inline

Definition at line 79 of file UIDragPanel.cs.

80 {
81 ped.useDragThreshold = false;
82 }

◆ OnPointerDown()

void UIDragPanel.OnPointerDown ( PointerEventData  data)
inline

Definition at line 53 of file UIDragPanel.cs.

54 {
55 if (enable && data.button == PointerEventData.InputButton.Left)
56 {
57 if (container == null)
58 {
59 container = target.parent as RectTransform;
60 }
61 originalPanelLocalPosition = target.localPosition;
62 RectTransformUtility.ScreenPointToLocalPointInRectangle(container, data.position, data.pressEventCamera, out originalLocalPointerPosition);
63 dragging = true;
64 }
65 }
static bool dragging
Definition: UIDragPanel.cs:7

References container, dragging, enable, originalLocalPointerPosition, originalPanelLocalPosition, and target.

◆ OnPointerUp()

void UIDragPanel.OnPointerUp ( PointerEventData  data)
inline

Definition at line 67 of file UIDragPanel.cs.

68 {
69 if (enable && data.button == PointerEventData.InputButton.Left)
70 {
71 if (axisY && axisX && autoAnchor)
72 {
73 target.SetAnchor();
74 }
75 dragging = false;
76 }
77 }
bool autoAnchor
Definition: UIDragPanel.cs:25

References autoAnchor, axisX, axisY, dragging, enable, and target.

◆ SetTarget()

void UIDragPanel.SetTarget ( RectTransform  r)
inline

Definition at line 43 of file UIDragPanel.cs.

44 {
45 target = (bound = r);
46 container = target.parent as RectTransform;
47 }

References bound, container, and target.

Member Data Documentation

◆ autoAnchor

bool UIDragPanel.autoAnchor

Definition at line 25 of file UIDragPanel.cs.

Referenced by OnPointerUp().

◆ axisX

bool UIDragPanel.axisX = true

Definition at line 21 of file UIDragPanel.cs.

Referenced by ClampToWindow(), and OnPointerUp().

◆ axisY

bool UIDragPanel.axisY = true

Definition at line 19 of file UIDragPanel.cs.

Referenced by ClampToWindow(), and OnPointerUp().

◆ bound

RectTransform UIDragPanel.bound

Definition at line 15 of file UIDragPanel.cs.

Referenced by Awake(), ClampToWindow(), Widget.OnManagerActivate(), and SetTarget().

◆ clamp

bool UIDragPanel.clamp = true

Definition at line 27 of file UIDragPanel.cs.

Referenced by OnDrag().

◆ container

RectTransform UIDragPanel.container

Definition at line 17 of file UIDragPanel.cs.

Referenced by OnDrag(), Widget.OnManagerActivate(), OnPointerDown(), and SetTarget().

◆ dragging

bool UIDragPanel.dragging
static

Definition at line 7 of file UIDragPanel.cs.

Referenced by OnPointerDown(), OnPointerUp(), and BaseTileSelector.OnUpdate().

◆ enable

bool UIDragPanel.enable = true

Definition at line 23 of file UIDragPanel.cs.

Referenced by OnDrag(), OnPointerDown(), and OnPointerUp().

◆ onDrag

Action UIDragPanel.onDrag

Definition at line 29 of file UIDragPanel.cs.

Referenced by OnDrag().

◆ originalLocalPointerPosition

Vector2 UIDragPanel.originalLocalPointerPosition
private

Definition at line 9 of file UIDragPanel.cs.

Referenced by OnDrag(), and OnPointerDown().

◆ originalPanelLocalPosition

Vector3 UIDragPanel.originalPanelLocalPosition
private

Definition at line 11 of file UIDragPanel.cs.

Referenced by OnDrag(), and OnPointerDown().

◆ target

RectTransform UIDragPanel.target

The documentation for this class was generated from the following file: