using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using SHADE; namespace SHADE_Scripting.UI { public class MinusTimerText: Script { public float duration = 0.5f; private Vector3 startPos; [NonSerialized] TweenThread thread; protected override void awake() { Transform transform = GetComponent(); if(transform) { startPos = transform.LocalPosition; } } protected override void start() { thread = TweenManager.CreateTweenThread(duration, 1.0f, 0.0f, EASING_METHOD.LINEAR); thread.SetResetOnInactive(GameObject); } protected override void update() { if(thread != null) { TextRenderable text = GetComponent(); if (text) { Color temp = text.TextColor; temp.a = thread.GetValue(); text.TextColor = temp; } if(thread.IsCompleted()) { GameObject.SetActive(false); } } Transform transform = GetComponent(); if(transform) { Vector3 temp = transform.LocalPosition; temp.y -= (float)Time.DeltaTime; transform.LocalPosition = temp; } } public void Reset() { GameObject.SetActive(true); thread.Reset(); Transform transform = GetComponent(); if (transform) { transform.LocalPosition = startPos; } } } }