You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
45 lines
1.0 KiB
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using DG.Tweening;
|
|
using System;
|
|
using System.Collections;
|
|
|
|
public class TextWrite : MonoBehaviour
|
|
{
|
|
private Text _text;
|
|
[SerializeField]
|
|
float speed=0.15f;
|
|
private void Start()
|
|
{
|
|
_text = GetComponent<Text>();
|
|
string str = _text.text;
|
|
_text.text = "";
|
|
_text.DOText(str, str.Length * speed, false);
|
|
}
|
|
|
|
public void ChangeText(string str)
|
|
{
|
|
|
|
_text.DOText("",0.01f);
|
|
_text.DOText(str, str.Length * speed, true);
|
|
|
|
}
|
|
public void ChangeText(string str,Action action)
|
|
{
|
|
if (str == "")
|
|
{
|
|
_text.transform.parent.gameObject.SetActive(false);
|
|
PassManager.Instance.StartTimeAction(0, action);
|
|
return;
|
|
}
|
|
_text.DOText("", 0.01f);
|
|
_text.DOText(str, str.Length * speed, true);
|
|
float time = str.Length * speed;
|
|
Debug.Log(time);
|
|
PassManager.Instance.StartTimeAction( time, action);
|
|
}
|
|
|
|
|
|
}
|