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

Public Member Functions

virtual void OnPointerEnter (PointerEventData data)
 
virtual void OnPointerExit (PointerEventData data)
 
void Pop ()
 
void Depop ()
 
UIContextMenu CreateMenu ()
 
void PositionMenu ()
 

Public Attributes

RectTransform _rect
 
bool isPointerOver
 
UIContextMenu parent
 
string id
 
UIContextMenu menu
 
UIContextMenu defaultMenu
 
Vector2 margin = new Vector2(8f, 10f)
 
float bottomFix
 
- Public Attributes inherited from UIContextMenuItem
Text textName
 
Button button
 
Toggle toggle
 
Slider slider
 
Text textSlider
 

Private Member Functions

void Awake ()
 
void Update ()
 

Detailed Description

Definition at line 5 of file UIContextMenuPopper.cs.

Member Function Documentation

◆ Awake()

void UIContextMenuPopper.Awake ( )
inlineprivate

Definition at line 27 of file UIContextMenuPopper.cs.

28 {
29 _rect = base.transform as RectTransform;
30 }

References _rect.

◆ CreateMenu()

UIContextMenu UIContextMenuPopper.CreateMenu ( )
inline

Definition at line 80 of file UIContextMenuPopper.cs.

81 {
82 menu = UnityEngine.Object.Instantiate(defaultMenu);
83 menu.transform.SetParent(base.transform, worldPositionStays: false);
84 menu.popper = this;
85 menu.depth = parent.depth + 1;
86 menu.parent = parent;
87 if (parent.system)
88 {
89 menu.bg.material = parent.matBlur;
90 }
91 return menu;
92 }
Material matBlur

References defaultMenu, UIContextMenu.matBlur, menu, parent, and UIContextMenu.system.

Referenced by UIContextMenu.AddChild(), and Pop().

◆ Depop()

void UIContextMenuPopper.Depop ( )
inline

Definition at line 75 of file UIContextMenuPopper.cs.

76 {
77 menu.Hide();
78 }

References UIContextMenu.Hide(), and menu.

Referenced by Pop(), and Update().

◆ OnPointerEnter()

virtual void UIContextMenuPopper.OnPointerEnter ( PointerEventData  data)
inlinevirtual

Definition at line 32 of file UIContextMenuPopper.cs.

33 {
34 isPointerOver = true;
35 }

References isPointerOver.

◆ OnPointerExit()

virtual void UIContextMenuPopper.OnPointerExit ( PointerEventData  data)
inlinevirtual

Definition at line 37 of file UIContextMenuPopper.cs.

38 {
39 isPointerOver = false;
40 }

References isPointerOver.

◆ Pop()

void UIContextMenuPopper.Pop ( )
inline

Definition at line 54 of file UIContextMenuPopper.cs.

55 {
57 {
58 UIContextMenuPopper[] componentsInChildren = UIContextMenu.Current.GetComponentsInChildren<UIContextMenuPopper>();
59 for (int i = 0; i < componentsInChildren.Length; i++)
60 {
61 componentsInChildren[i].Depop();
62 }
63 }
64 if (menu == null)
65 {
66 CreateMenu();
67 }
68 menu.Show();
69 if (parent != null)
70 {
72 }
73 }
UIContextMenu CreateMenu()
void Show(UIItem i)
static UIContextMenu Current
bool hideOnMouseLeave

References CreateMenu(), UIContextMenu.Current, Depop(), UIContextMenu.hideOnMouseLeave, menu, parent, PositionMenu(), and UIContextMenu.Show().

Referenced by Update().

◆ PositionMenu()

void UIContextMenuPopper.PositionMenu ( )
inline

Definition at line 94 of file UIContextMenuPopper.cs.

95 {
96 RectTransform rect = menu._rect;
97 rect.RebuildLayout(recursive: true);
98 Vector2 zero = Vector2.zero;
99 zero.x = _rect.sizeDelta.x - margin.x;
100 zero.y = _rect.sizeDelta.y * -1f - margin.y;
101 rect.pivot = new Vector2(0f, 1f);
102 rect.anchoredPosition = zero;
103 if (parent.transform.position.x + parent._rect.sizeDelta.x * (1f - parent._rect.pivot.x) > (float)Screen.width - rect.sizeDelta.x || menu.alwaysPopLeft)
104 {
105 zero.x = margin.x;
106 rect.pivot = new Vector2(1f, menu._rect.pivot.y);
107 }
108 zero.x = (int)zero.x;
109 zero.y = (int)zero.y;
110 rect.anchoredPosition = zero;
111 if (rect.position.y - rect.sizeDelta.y * BaseCore.Instance.uiScale < 0f)
112 {
113 Vector3 position = rect.position;
114 position.y = rect.sizeDelta.y * BaseCore.Instance.uiScale;
115 rect.position = position;
116 }
117 }
virtual float uiScale
Definition: BaseCore.cs:46
static BaseCore Instance
Definition: BaseCore.cs:11
RectTransform _rect

References UIContextMenu._rect, UIContextMenu.alwaysPopLeft, BaseCore.Instance, margin, menu, parent, and BaseCore.uiScale.

Referenced by Pop().

◆ Update()

void UIContextMenuPopper.Update ( )
inlineprivate

Definition at line 42 of file UIContextMenuPopper.cs.

43 {
44 if (isPointerOver && !menu.gameObject.activeSelf && parent.timeSinceOpen > 0.1f && !Input.GetMouseButton(0))
45 {
46 Pop();
47 }
48 if (!isPointerOver && !Input.GetMouseButton(0) && UIContextMenu.Current.hideOnMouseLeave && !menu.isPointerOver)
49 {
50 Depop();
51 }
52 }
float timeSinceOpen

References UIContextMenu.Current, Depop(), UIContextMenu.hideOnMouseLeave, UIContextMenu.isPointerOver, isPointerOver, menu, parent, Pop(), and UIContextMenu.timeSinceOpen.

Member Data Documentation

◆ _rect

RectTransform UIContextMenuPopper._rect

Definition at line 8 of file UIContextMenuPopper.cs.

Referenced by Awake().

◆ bottomFix

float UIContextMenuPopper.bottomFix

Definition at line 25 of file UIContextMenuPopper.cs.

◆ defaultMenu

UIContextMenu UIContextMenuPopper.defaultMenu

Definition at line 21 of file UIContextMenuPopper.cs.

Referenced by CreateMenu().

◆ id

string UIContextMenuPopper.id

Definition at line 17 of file UIContextMenuPopper.cs.

Referenced by UIContextMenu.AddOrGetChild().

◆ isPointerOver

bool UIContextMenuPopper.isPointerOver

Definition at line 11 of file UIContextMenuPopper.cs.

Referenced by OnPointerEnter(), OnPointerExit(), UIContextMenu.Update(), and Update().

◆ margin

Vector2 UIContextMenuPopper.margin = new Vector2(8f, 10f)

Definition at line 23 of file UIContextMenuPopper.cs.

Referenced by PositionMenu().

◆ menu

◆ parent

UIContextMenu UIContextMenuPopper.parent

Definition at line 14 of file UIContextMenuPopper.cs.

Referenced by UIContextMenu.AddButton(), CreateMenu(), Pop(), PositionMenu(), and Update().


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