-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUIFramework_Example_PopupText.cs
91 lines (64 loc) · 2.52 KB
/
UIFramework_Example_PopupText.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#region Header
/* ============================================
* Author : Strix
* Initial Creation Date : 2020-01-30
* Summary :
* Template : For Unity Editor V1
============================================ */
#endregion Header
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
namespace UIFramework
{
/// <summary>
///
/// </summary>
public class UIFramework_Example_PopupText : UIFramework_ExampleCanvasBase, IHas_UIButton<UIFramework_Example_PopupText.EUIButton>
{
/* const & readonly declaration */
/* enum & struct declaration */
public enum EUIButton
{
Button_ShowPopupText,
}
/* public - Field declaration */
public PopupText pPopupText;
/* protected & private - Field declaration */
Canvas _pCanvas;
InputField _pInputField;
// ========================================================================== //
/* public - [Do~Something] Function */
// ========================================================================== //
/* protected - [Override & Unity API] */
protected override void OnAwake()
{
base.OnAwake();
_pCanvas = GetComponent<Canvas>();
_pInputField = GetComponentInChildren<InputField>();
if (string.IsNullOrEmpty(_pInputField.text))
_pInputField.text = Random.Range(0, 1000).ToString();
}
public void IHas_UIButton_OnClickButton(UIButtonMessage<EUIButton> sButtonMsg)
{
switch (sButtonMsg.eButtonName)
{
case EUIButton.Button_ShowPopupText:
Vector3 vecSpawnPos = sButtonMsg.pButtonInstance_OrNull.transform.position;
vecSpawnPos.x += Random.Range(-5f, 5f);
vecSpawnPos.y += Random.Range(-5f, 5f);
PopupText pPopupTextClone = Instantiate(pPopupText);
pPopupTextClone.transform.position = vecSpawnPos;
pPopupTextClone.DoShow(_pCanvas, _pInputField.text, vecSpawnPos);
break;
default:
break;
}
}
/* protected - [abstract & virtual] */
// ========================================================================== //
#region Private
#endregion Private
}
}