You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
768 B
C#
30 lines
768 B
C#
3 months ago
|
using System;
|
||
|
using D2D.UI;
|
||
|
using D2D.Utilities;
|
||
|
using TMPro;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace D2D.UI
|
||
|
{
|
||
|
public class RandomPhraseLabel : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private string[] _phrases;
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
var uiLabel = GetComponent<TextMeshProUGUI>();
|
||
|
var worldUILabel = GetComponent<TextMeshPro>();
|
||
|
|
||
|
if (uiLabel == null && worldUILabel == null)
|
||
|
{
|
||
|
throw new NullReferenceException("text wanted to have default font");
|
||
|
}
|
||
|
|
||
|
if (uiLabel != null)
|
||
|
uiLabel.text = _phrases.GetRandomElement();
|
||
|
|
||
|
if (worldUILabel != null)
|
||
|
worldUILabel.text = _phrases.GetRandomElement();
|
||
|
}
|
||
|
}
|
||
|
}
|