HKI Core
HKI Core
UI
Tooltip
UITooltip.cs
Go to the documentation of this file.
1
using
UnityEngine
;
2
using
UnityEngine
.EventSystems;
3
using
HKI
.
Core
.
Loc
;
4
5
namespace
HKI
.Core.UI
6
{
10
public
class
UITooltip
: MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
11
{
12
// Public enums
13
[
System
.Serializable]
14
public
enum
TooltipAlingments
15
{
16
BottomRight,
17
TopLeft,
18
BottomLeft,
19
TopRight
20
}
21
22
// Public variables
23
[SerializeField]
TooltipAlingments
TooltipAlingment =
TooltipAlingments
.BottomRight;
24
[SerializeField]
TextLocalization
TooltipTextLocalization = null;
25
26
// Getter
27
public
TooltipAlingments
GetTooltipAlingment {
get
{
return
TooltipAlingment; } }
28
29
// OnDisable function
30
void
OnDisable
()
31
{
32
if
(
UITooltipController
.
Instance
== null)
33
{
34
//Debug.LogError("(UITooltipController)" + name + " you are trying to hide a tooltip but there is no tooltip controller in this scene(s)!");
35
return
;
36
}
37
38
UITooltipController
.
Instance
.
HideTooltip
(
this
);
39
}
40
41
// Interface implementations
42
public
void
ChangeTooltipTextLocalization
(
TextLocalization
tl)
43
{
44
if
(tl != null)
45
TooltipTextLocalization = tl;
46
}
47
48
public
void
OnPointerEnter
(PointerEventData eventData)
49
{
50
if
(TooltipTextLocalization == null)
51
{
52
Debug.LogError(
"(UITooltip)"
+ name +
" you are trying use a text localization but there is no text localization attached to this tooltip!"
);
53
return
;
54
}
55
56
if
(
UITooltipController
.
Instance
== null)
57
{
58
Debug.LogError(
"(UITooltipController)"
+ name +
" you are trying to show a tooltip but there is no tooltip controller in this scene(s)!"
);
59
return
;
60
}
61
62
UITooltipController
.
Instance
.
ShowTooltip
(
this
, TooltipTextLocalization);
63
}
64
65
public
void
OnPointerExit
(PointerEventData eventData)
66
{
67
if
(
UITooltipController
.
Instance
== null)
68
{
69
Debug.LogError(
"(UITooltipController)"
+ name +
" you are trying to hide a tooltip but there is no tooltip controller in this scene(s)!"
);
70
return
;
71
}
72
73
UITooltipController
.
Instance
.
HideTooltip
(
this
);
74
}
75
}
76
}
HKI.Core
HKI.Core.UI.UITooltip.OnDisable
void OnDisable()
Definition:
UITooltip.cs:30
HKI.Core.Loc.TextLocalization
This ScriptableObject contains as a container for all text localization information.
Definition:
TextLocalization.cs:10
System
HKI.Core.UI.UITooltipController.ShowTooltip
void ShowTooltip(UITooltip tooltip, TextLocalization textLocalization)
Definition:
UITooltipController.cs:81
HKI.Core.UI.UITooltipController
This MonoBehaviour is responseble for the displaying of a tooltip. It needs a window GameObject and a...
Definition:
UITooltipController.cs:13
HKI.Core.UI.UITooltip.TooltipAlingments
TooltipAlingments
Definition:
UITooltip.cs:14
HKI.Core.UI.UITooltip.ChangeTooltipTextLocalization
void ChangeTooltipTextLocalization(TextLocalization tl)
Definition:
UITooltip.cs:42
HKI.Core.UI.UITooltipController.Instance
static UITooltipController Instance
Definition:
UITooltipController.cs:16
HKI.Core.UI.UITooltipController.HideTooltip
void HideTooltip(UITooltip tooltip)
Definition:
UITooltipController.cs:102
HKI.Core.UI.UITooltip
Attached to a GameObject with a RectTransform this MonoBehaviour will display a tooltip if the mouse ...
Definition:
UITooltip.cs:10
HKI.Core.UI.UITooltip.OnPointerEnter
void OnPointerEnter(PointerEventData eventData)
Definition:
UITooltip.cs:48
UnityEngine
HKI.Core.UI.UITooltip.OnPointerExit
void OnPointerExit(PointerEventData eventData)
Definition:
UITooltip.cs:65
HKI.Core.Loc
HKI
Generated by
1.8.13