| | 1 | | using System.Collections.Generic; |
| | 2 | | using TMPro; |
| | 3 | | using UnityEngine; |
| | 4 | | using UnityEngine.Serialization; |
| | 5 | | using UnityEngine.UI; |
| | 6 | |
|
| | 7 | | namespace DCL.Controllers.LoadingScreenV2 |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// View responsible of showing the corresponding provided Hint by LoadingScreenHintsController |
| | 11 | | /// </summary> |
| | 12 | | public class HintView : MonoBehaviour, IHintView |
| | 13 | | { |
| | 14 | | [SerializeField] internal TMP_Text hintText; |
| | 15 | | [SerializeField] internal Image hintImage; |
| | 16 | |
|
| | 17 | | public void Initialize(Hint hint, Texture2D texture, bool startAsActive = false) |
| | 18 | | { |
| | 19 | | try |
| | 20 | | { |
| 0 | 21 | | if (hintText == null) |
| 0 | 22 | | throw new System.Exception("HintView - HintText is not assigned!"); |
| 0 | 23 | | if (hintImage == null) |
| 0 | 24 | | throw new System.Exception("HintView - HintImage is not assigned!"); |
| 0 | 25 | | } |
| | 26 | | catch (System.Exception e) |
| | 27 | | { |
| 0 | 28 | | Debug.LogError(e); |
| 0 | 29 | | throw; |
| | 30 | | } |
| | 31 | |
|
| 0 | 32 | | hintText.text = hint.Title; |
| | 33 | |
|
| 0 | 34 | | if (texture != null) |
| 0 | 35 | | hintImage.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero); |
| | 36 | |
|
| 0 | 37 | | ToggleHint(startAsActive); |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | public void ToggleHint(bool active) |
| | 41 | | { |
| 0 | 42 | | if (this != null) |
| 0 | 43 | | gameObject.SetActive(active); |
| 0 | 44 | | } |
| | 45 | | } |
| | 46 | | } |