57 lines
1.5 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Assets.Scenes.Ride.Scripts
{
public class VersionScript : MonoBehaviour
{
long _delayTime = 0;
Text appVersion;
void Start()
{
appVersion = transform.GetComponent<Text>();
if (appVersion != null)
{
appVersion.lineSpacing = 1;
appVersion.verticalOverflow = VerticalWrapMode.Overflow;
appVersion.alignment = TextAnchor.LowerRight;
appVersion.text = $"{"V" + App.AppVersion}";
}
}
private void Update()
{
if (_delayTime != App.delayTime && appVersion != null)
{
_delayTime = App.delayTime;
if (_delayTime != -1)
{
appVersion.text = $"<color={getColor(_delayTime)}>{_delayTime.ToString("0")}ms</color>\n{"V" + App.AppVersion}";
}
else
{
appVersion.text = "V" + App.AppVersion;
}
}
}
private string getColor(long a)
{
if (a > 0 && a <= 50)
{
return "#4FE944";
}
else if (a > 50 && a <= 100)
{
return "#E9BF44";
}
else
{
return "#EE2929";
}
}
}
}