45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using UnityEngine;
|
|
using TMPro;
|
|
using System.Collections;
|
|
|
|
public class ComboDisplay : MonoBehaviour
|
|
{
|
|
public TextMeshProUGUI comboInfoText;
|
|
public float floatSpeed = 1000.0f;
|
|
public float displayTime = 1.0f; // Adjust the duration you want the combo text to be displayed
|
|
Vector3 initialPosition;
|
|
|
|
private void Start()
|
|
{
|
|
comboInfoText = GameObject.Find("UI").transform.GetChild(0).GetChild(11).gameObject.GetComponent<TextMeshProUGUI>();
|
|
initialPosition = comboInfoText.transform.position;
|
|
}
|
|
|
|
public void ShowComboText(string comboText)
|
|
{
|
|
StartCoroutine(FloatComboText(comboText));
|
|
}
|
|
|
|
IEnumerator FloatComboText(string comboText)
|
|
{
|
|
comboInfoText.text = comboText;
|
|
comboInfoText.gameObject.SetActive(true);
|
|
|
|
float elapsedTime = 0f;
|
|
|
|
|
|
while (elapsedTime < displayTime)
|
|
{
|
|
float translation = floatSpeed;
|
|
comboInfoText.transform.Translate(Vector3.up * translation);
|
|
|
|
elapsedTime += Time.deltaTime;
|
|
yield return null;
|
|
}
|
|
|
|
comboInfoText.gameObject.SetActive(false);
|
|
comboInfoText.transform.position = initialPosition;
|
|
|
|
}
|
|
}
|