| | 1 | | using DCL.ECSComponents; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | public class ECSInteractionHoverMonoBehavior : MonoBehaviour, IECSInteractionHoverCanvas |
| | 5 | | { |
| | 6 | | [SerializeField] internal ECSInteractionHoverTooltipMonoBehavior[] _tooltips; |
| | 7 | | [SerializeField] internal Sprite[] _icons; |
| | 8 | | [SerializeField] internal ShowHideAnimator _showHideAnimator; |
| | 9 | |
|
| 6 | 10 | | internal readonly string[] inputText = new[] |
| | 11 | | { |
| | 12 | | null, "E", "F", null, |
| | 13 | | "W", "S", "D", "A", |
| | 14 | | "SPACE BAR", "LSHIFT", |
| | 15 | | "1", "2", "3", "4" |
| | 16 | | }; |
| | 17 | |
|
| 0 | 18 | | public int tooltipsCount => _tooltips.Length; |
| | 19 | |
|
| | 20 | | public void Show() |
| | 21 | | { |
| 1 | 22 | | _showHideAnimator.Show(); |
| 1 | 23 | | } |
| | 24 | |
|
| | 25 | | public void Hide() |
| | 26 | | { |
| 1 | 27 | | _showHideAnimator.Hide(); |
| 1 | 28 | | } |
| | 29 | |
|
| | 30 | | public void SetTooltipInput(int tooltipIndex, ActionButton button) |
| | 31 | | { |
| | 32 | | switch (button) |
| | 33 | | { |
| | 34 | | case ActionButton.Pointer: |
| 1 | 35 | | _tooltips[tooltipIndex].SetInputIcon(_icons[0]); |
| 1 | 36 | | break; |
| | 37 | | case ActionButton.Any: |
| 1 | 38 | | _tooltips[tooltipIndex].SetInputIcon(_icons[1]); |
| 1 | 39 | | break; |
| | 40 | | default: |
| 12 | 41 | | int buttonIndex = (int)button; |
| 12 | 42 | | if (buttonIndex < inputText.Length && !string.IsNullOrEmpty(inputText[buttonIndex])) |
| 12 | 43 | | _tooltips[tooltipIndex].SetInputText(inputText[buttonIndex]); |
| | 44 | | break; |
| | 45 | | } |
| 12 | 46 | | } |
| | 47 | |
|
| | 48 | | public void SetTooltipText(int tooltipIndex, string text) |
| | 49 | | { |
| 2 | 50 | | _tooltips[tooltipIndex].SetText(text); |
| 2 | 51 | | } |
| | 52 | |
|
| | 53 | | public void SetTooltipActive(int tooltipIndex, bool active) |
| | 54 | | { |
| 2 | 55 | | _tooltips[tooltipIndex].SetActive(active); |
| 2 | 56 | | } |
| | 57 | | } |