Skip to content

Instantly share code, notes, and snippets.

@unity3dcollege
Created October 5, 2017 00:17
Show Gist options
  • Save unity3dcollege/13162992197c43756160aa08d0b44cfe to your computer and use it in GitHub Desktop.
Save unity3dcollege/13162992197c43756160aa08d0b44cfe to your computer and use it in GitHub Desktop.
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