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.
34 lines
584 B
C#
34 lines
584 B
C#
using UnityEngine;
|
|
using TMPro;
|
|
|
|
namespace Projectiles.UI
|
|
{
|
|
public class UIHitNumber : UIBehaviour
|
|
{
|
|
// PUBLIC MEMBERS
|
|
|
|
public bool IsFinished => CanvasGroup.alpha <= 0f;
|
|
public Vector3 WorldPosition { get; set; }
|
|
|
|
// PRIVATE MEMBERS
|
|
|
|
[SerializeField]
|
|
private TextMeshProUGUI _text;
|
|
|
|
// PUBLIC METHODS
|
|
|
|
public void SetNumber(float value)
|
|
{
|
|
int intValue = Mathf.RoundToInt(value);
|
|
|
|
if (intValue == 0 && value != 0f)
|
|
{
|
|
// Do not show zero if not necessary
|
|
intValue = value > 0f ? 1 : -1;
|
|
}
|
|
|
|
_text.text = intValue.ToString();
|
|
}
|
|
}
|
|
}
|