53 lines
1.4 KiB
C#
53 lines
1.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 각종 유틸리티 사용 클래스
|
|
/// </summary>
|
|
public class UtilInfo : MonoBehaviour
|
|
{
|
|
[RuntimeInitializeOnLoadMethod]
|
|
static void OnRuntimeMethodLoad()
|
|
{
|
|
new GameObject("UtilInfo").AddComponent<UtilInfo>();
|
|
}
|
|
|
|
public static UtilInfo Ins;
|
|
|
|
private void Awake()
|
|
{
|
|
Ins = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
|
|
#region 타이핑 연출
|
|
Coroutine TypingCoroutine;
|
|
public void Set_TypeAction(string _text, TextMeshProUGUI _textobj, Action _act = null)
|
|
{
|
|
if (TypingCoroutine != null) StopCoroutine(TypingCoroutine);
|
|
TypingCoroutine = StartCoroutine(TypingAction(_text, _textobj, _act));
|
|
}
|
|
IEnumerator TypingAction(string _text, TextMeshProUGUI _textobj, Action _act)
|
|
{
|
|
string originText = _text, subText = "";
|
|
_textobj.text = "";
|
|
|
|
for (int i = 0; i < originText.Length + 1; i++)
|
|
{
|
|
yield return new WaitForSeconds(0.1f);
|
|
|
|
if (_textobj == null) break;
|
|
|
|
//SoundInfo.Ins.Play_OneShot(eSound.Typing);
|
|
subText = DSUtil.Format("{0}{1}", subText, originText.Substring(0, i));
|
|
_textobj.text = subText;
|
|
subText = "";
|
|
}
|
|
|
|
_act?.Invoke();
|
|
TypingCoroutine = null;
|
|
}
|
|
#endregion
|
|
} |