10 [AddComponentMenu(
"HKI/UI/UITooltipController")]
11 [RequireComponent(typeof(Canvas))]
12 [DisallowMultipleComponent]
18 [Header(
"General Properties")]
19 [SerializeField] GameObject TooltipWindowGO = null;
20 [SerializeField] GameObject TooltipTextGO = null;
24 [SerializeField]
float DelayTime = 2.0f;
26 [SerializeField] Vector3 TopLeftOffset =
new Vector3();
27 [SerializeField] Vector3 TopRightOffset =
new Vector3();
28 [SerializeField] Vector3 BottomLeftOffset =
new Vector3();
29 [SerializeField] Vector3 BottomRightOffset =
new Vector3();
32 Transform tooltipWindowTransform = null;
38 Coroutine showTooltipCoroutine = null;
46 DontDestroyOnLoad(gameObject);
54 if(TooltipWindowGO == null)
56 Debug.LogError(
"UITooltipController.Awake(): TooltipWindowGO is null!");
60 if(TooltipTextGO == null)
62 Debug.LogError(
"UITooltipController.Awake(): TooltipTextGO is null!");
66 tooltipWindowTransform = TooltipWindowGO.transform;
70 TooltipWindowGO.SetActive(
false);
83 if(textLocalization == null)
85 Debug.LogError(
"(UITooltipController) you are trying use a text localization but the given text localization is null!");
89 if(showTooltipCoroutine != null)
91 StopCoroutine(showTooltipCoroutine);
92 TooltipWindowGO.SetActive(
false);
93 showTooltipCoroutine = null;
94 currentActiveTooltip = null;
97 currentActiveTooltip = tooltip;
99 showTooltipCoroutine = StartCoroutine(ShowTooltipCoroutine(textLocalization));
104 if(currentActiveTooltip == tooltip)
106 StopCoroutine(showTooltipCoroutine);
107 TooltipWindowGO.SetActive(
false);
108 showTooltipCoroutine = null;
109 currentActiveTooltip = null;
117 yield
return new WaitForSeconds(DelayTime);
128 ((RectTransform)tooltipWindowTransform).pivot =
new Vector2(0.0f, 1.0f);
132 ((RectTransform)tooltipWindowTransform).pivot =
new Vector2(1.0f, 0.0f);
136 ((RectTransform)tooltipWindowTransform).pivot =
new Vector2(1.0f, 1.0f);
140 ((RectTransform)tooltipWindowTransform).pivot =
new Vector2(0.0f, 0.0f);
146 TooltipWindowGO.SetActive(
true);
149 bool updatePosition =
true;
150 while(updatePosition)
163 tooltipWindowTransform.position = Input.mousePosition + BottomRightOffset;
167 tooltipWindowTransform.position = Input.mousePosition + TopLeftOffset;
171 tooltipWindowTransform.position = Input.mousePosition + BottomLeftOffset;
175 tooltipWindowTransform.position = Input.mousePosition + TopRightOffset;
string GetDefaultText()
This functions returns the default localization this will be the first TextElement. In the case there is no localization at all an empty string will be returned.
This ScriptableObject contains as a container for all text localization information.
string GetText(Language language)
This function returns the string in a specific language. If there is no localization element in the r...
void ChangeText(string text)
This class allows the use of the standard Unity UI Text component and the TextMeshPro component witho...
Special Variable enables the use of the SystemLanguage data type as a variable of the settings system...