#if TEXTMESHPRO_INSTALLED using TMPro; #endif using UnityEngine; using UnityEngine.UI; namespace EasyTalk.Display { /// /// This class is an implementation of a continue display, used to indicate to the player when they can continue during playback of dialogue. /// public class ContinueDisplay : DialoguePanel { /// /// The background image of the continue display. /// [Tooltip("The background image of the Continue Display.")] [SerializeField] private Image backgroundImage; #if TEXTMESHPRO_INSTALLED /// /// The text of the continue display. /// [Tooltip("The text element of the Continue Display.")] [SerializeField] private TMP_Text textMeshProText; #endif /// /// The text of the continue display. /// [Tooltip("The text element of the Continue Display.")] [SerializeField] private Text text; /// /// Initializes and hides the display on awake. /// private void Awake() { Init(); HideImmediately(); } /// /// Resets the button to normal display mode. /// private void ResetButton() { DialogueButton continueButton = GetComponent(); if (continueButton != null) { continueButton.DisplayNormal(); } } /// /// If the continue display has a DialogueButton component, calling this method will make it interactable so that the player can interact with it with the mouse. /// private void EnableButton() { DialogueButton continueButton = GetComponent(); if (continueButton != null) { continueButton.Interactable = true; } } /// /// If the continue display has a DialogueButton component, calling this method will make it non-interactable so that it can not be interacted with by the player/mouse. /// private void DisableButton() { DialogueButton continueButton = GetComponent(); if (continueButton != null) { continueButton.Interactable = false; } } /// /// Called whenever the display finishes being shown. IF the continue display has a DialogueButton component, it is set to be interactable, meaning the player can click on /// or interact with the button. /// protected override void OnShowComplete() { base.OnShowComplete(); EnableButton(); } /// /// Called whenever the display is being hidden. If the continue display has a DialogueButton component, it is set to be non-interactable, meaning the player cannot click on /// or interact with the button. /// protected override void OnHideStart() { base.OnHideStart(); DisableButton(); } /// /// Gets or sets the background image of the display. /// public Image BackgroundImage { get { return backgroundImage; } set { backgroundImage = value; } } /// /// Gets or sets the standard Unity Text component of the display. /// public Text StandardText { get { return this.text; } set { this.text = value; } } #if TEXTMESHPRO_INSTALLED /// /// Gets or sets the TextMeshPro Text component of the display. /// public TMP_Text TMPText { get { return textMeshProText; } set { textMeshProText = value; } } #endif private void OnValidate() { #if TEXTMESHPRO_INSTALLED if (this.TMPText == null) { TMP_Text[] tmpTextComponents = GetComponentsInChildren(true); foreach (TMP_Text txt in tmpTextComponents) { if (txt.gameObject.name.Contains("ContinueText") && txt.gameObject.name.Contains("TMP")) { this.TMPText = txt; break; } } } #endif } } }