Add project files.
This commit is contained in:
36
Assets/Cryville/Crtr/NetworkTaskWorkerTicker.cs
Normal file
36
Assets/Cryville/Crtr/NetworkTaskWorkerTicker.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Cryville.Common.Unity;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class NetworkTaskWorkerTicker : MonoBehaviour {
|
||||
private Image _image;
|
||||
private float timer;
|
||||
#pragma warning disable IDE0051
|
||||
void Awake() {
|
||||
_image = GetComponent<Image>();
|
||||
}
|
||||
static Color _idleColor = new Color(1, 1, 1, .5f);
|
||||
static Color _tickColor1 = new Color(1, 1, 1, 1);
|
||||
static Color _tickColor2 = new Color(1, 1, 1, .8f);
|
||||
static Color _suspendedColor = new Color(1, 0, 0, 1);
|
||||
void Update() {
|
||||
switch (Game.NetworkTaskWorker.TickBackgroundTasks()) {
|
||||
case WorkerStatus.Idle:
|
||||
_image.color = _idleColor;
|
||||
timer = 0f;
|
||||
break;
|
||||
case WorkerStatus.Suspended:
|
||||
_image.color = _suspendedColor;
|
||||
timer = 0f;
|
||||
break;
|
||||
case WorkerStatus.Working:
|
||||
timer += Time.deltaTime;
|
||||
timer %= 0.5f;
|
||||
_image.color = timer < 0.25f ? _tickColor1 : _tickColor2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user