Revize 54fb8008
Přidáno uživatelem Zuzana Káčereková před více než 3 roky(ů)
Client/Client/Assets/Scripts/UI/BuildingPanel.cs | ||
---|---|---|
4 | 4 |
using UnityEngine.EventSystems; |
5 | 5 |
using UnityEngine.UI; |
6 | 6 |
|
7 |
/// <summary> |
|
8 |
/// Find A Building panel |
|
9 |
/// |
|
10 |
/// Autor: kacerekz |
|
11 |
/// |
|
12 |
/// </summary> |
|
7 | 13 |
public class BuildingPanel : PopUpPanel |
8 | 14 |
{ |
15 |
/// <summary> |
|
16 |
/// Alias dictonary |
|
17 |
/// </summary> |
|
9 | 18 |
public static Dictionary<string, SpriteRenderer> aliases = new Dictionary<string, SpriteRenderer>(); |
10 | 19 |
|
20 |
/// <summary> |
|
21 |
/// Map |
|
22 |
/// </summary> |
|
11 | 23 |
public WebGLMapController map; |
24 |
|
|
25 |
/// <summary> |
|
26 |
/// Side panel button |
|
27 |
/// </summary> |
|
12 | 28 |
public Button setBuildingButton; |
29 |
|
|
30 |
/// <summary> |
|
31 |
/// Confirm button in the finder panel |
|
32 |
/// </summary> |
|
13 | 33 |
public Button findBuildingButton; |
34 |
|
|
35 |
/// <summary> |
|
36 |
/// Input field |
|
37 |
/// </summary> |
|
14 | 38 |
public InputField input; |
39 |
|
|
40 |
/// <summary> |
|
41 |
/// Suggestion dropdown |
|
42 |
/// </summary> |
|
15 | 43 |
public Dropdown suggestion; |
16 | 44 |
|
45 |
/// <summary> |
|
46 |
/// Find selected building |
|
47 |
/// </summary> |
|
17 | 48 |
public void OnFindBuildingButton() |
18 | 49 |
{ |
19 | 50 |
if (aliases.ContainsKey(input.text.ToUpper())) |
... | ... | |
22 | 53 |
OnExitButtonClicked(); |
23 | 54 |
} |
24 | 55 |
|
56 |
/// <summary> |
|
57 |
/// Update text as per dropdown selection |
|
58 |
/// </summary> |
|
25 | 59 |
public void OnDropdownValueChanged() |
26 | 60 |
{ |
27 | 61 |
input.text = suggestion.options[suggestion.value].text; |
28 | 62 |
Debug.Log("set text: " + suggestion.options[suggestion.value].text); |
29 | 63 |
} |
30 | 64 |
|
65 |
/// <summary> |
|
66 |
/// Process input when an edit ends |
|
67 |
/// </summary> |
|
31 | 68 |
public void OnEndInputEdit() |
32 | 69 |
{ |
33 | 70 |
findBuildingButton.interactable = false; |
... | ... | |
46 | 83 |
} |
47 | 84 |
} |
48 | 85 |
|
86 |
/// <summary> |
|
87 |
/// Process changes in user input |
|
88 |
/// </summary> |
|
49 | 89 |
public void OnInputChanged() |
50 | 90 |
{ |
51 | 91 |
//Debug.Log(input.text); |
... | ... | |
80 | 120 |
if (isActiveAndEnabled) StartCoroutine(MoveCaretToEnd()); |
81 | 121 |
} |
82 | 122 |
|
123 |
/// <summary> |
|
124 |
/// Move caret to end of input field on next frame |
|
125 |
/// </summary> |
|
126 |
/// <returns>0</returns> |
|
83 | 127 |
IEnumerator MoveCaretToEnd() |
84 | 128 |
{ |
85 | 129 |
yield return 0; |
86 | 130 |
input.MoveTextEnd(false); |
87 | 131 |
} |
88 | 132 |
|
133 |
/// <summary> |
|
134 |
/// Reset panel |
|
135 |
/// </summary> |
|
89 | 136 |
public void OnExit() |
90 | 137 |
{ |
91 | 138 |
input.text = ""; |
Také k dispozici: Unified diff
Last edits