Created
October 5, 2017 00:17
-
-
Save unity3dcollege/13162992197c43756160aa08d0b44cfe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using TMPro; | |
using UnityEngine; | |
public class CheckpointText : MonoBehaviour | |
{ | |
private TextMeshProUGUI tmText; | |
private Animator animator; | |
[SerializeField] | |
private float duration = 2f; | |
public static CheckpointText Instance { get; private set; } | |
private void Awake() | |
{ | |
Instance = this; | |
tmText = GetComponent<TMPro.TextMeshProUGUI>(); | |
animator = GetComponent<Animator>(); | |
} | |
public void ShowCheckpointText(string checkpointText) | |
{ | |
StartCoroutine(ShowCheckpointTextAsync(checkpointText)); | |
} | |
private IEnumerator ShowCheckpointTextAsync(string checkpointText) | |
{ | |
tmText.text = checkpointText; | |
animator.SetBool("Visible", true); | |
yield return new WaitForSeconds(duration); | |
animator.SetBool("Visible", false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment