Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
UIDropdown.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4using UnityEngine.EventSystems;
5using UnityEngine.UI;
6
7public class UIDropdown : Dropdown
8{
9 [NonSerialized]
10 public UIButton bl;
11
13
14 public override void OnCancel(BaseEventData eventData)
15 {
16 }
17
18 private void Update()
19 {
20 if (activeInstance == this && Input.GetMouseButtonDown(1))
21 {
22 Hide();
23 }
24 }
25
26 protected override void OnEnable()
27 {
28 base.OnEnable();
29 base.template.GetComponentInChildren<ScrollRect>().scrollSensitivity = UIScrollView.sensitivity;
30 }
31
32 protected override GameObject CreateBlocker(Canvas rootCanvas)
33 {
34 activeInstance = this;
35 return base.CreateBlocker(rootCanvas);
36 }
37
38 protected override void DestroyBlocker(GameObject blocker)
39 {
40 activeInstance = null;
41 if ((bool)bl)
42 {
43 UnityEngine.Object.Destroy(bl.gameObject);
44 bl = null;
45 }
46 base.DestroyBlocker(blocker);
47 }
48
49 public void SetList<TValue>(string name, IList<TValue> list, Func<TValue, int, string> getName, Action<int, TValue> onChange, bool notify = true)
50 {
51 int index = 0;
52 for (int i = 0; i < list.Count; i++)
53 {
54 if (getName(list[i], i) == name)
55 {
56 index = i;
57 break;
58 }
59 }
60 SetList(index, list, getName, onChange, notify);
61 }
62
63 public void SetList<TValue>(int _index, IList<TValue> list, Func<TValue, int, string> getName, Action<int, TValue> onChange, bool notify = true)
64 {
65 base.options.Clear();
66 for (int i = 0; i < list.Count; i++)
67 {
68 base.options.Add(new OptionData
69 {
70 text = getName(list[i], i)
71 });
72 }
73 base.onValueChanged.RemoveAllListeners();
74 base.onValueChanged.AddListener(delegate(int a)
75 {
76 onChange(a, list[a]);
77 });
78 if (notify)
79 {
80 base.value = _index;
81 }
82 else
83 {
84 SetValueWithoutNotify(_index);
85 }
86 RefreshShownValue();
87 }
88
89 public void Next()
90 {
91 if (base.value < base.options.Count - 1)
92 {
93 base.value++;
94 }
95 }
96
97 public void Prev()
98 {
99 if (base.value > 0)
100 {
101 base.value--;
102 }
103 }
104}
Definition: Hide.cs:4
void Next()
Definition: UIDropdown.cs:89
static UIDropdown activeInstance
Definition: UIDropdown.cs:12
UIButton bl
Definition: UIDropdown.cs:10
void Update()
Definition: UIDropdown.cs:18
void SetList< TValue >(string name, IList< TValue > list, Func< TValue, int, string > getName, Action< int, TValue > onChange, bool notify=true)
Definition: UIDropdown.cs:49
override void DestroyBlocker(GameObject blocker)
Definition: UIDropdown.cs:38
void Prev()
Definition: UIDropdown.cs:97
override GameObject CreateBlocker(Canvas rootCanvas)
Definition: UIDropdown.cs:32
override void OnCancel(BaseEventData eventData)
Definition: UIDropdown.cs:14
override void OnEnable()
Definition: UIDropdown.cs:26
static float sensitivity
Definition: UIScrollView.cs:7