From ba1faafd285f15c7c91720371f9f0ecd96fa6b27 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 18 Apr 2022 10:08:33 +0800 Subject: *bomb --- AlienSurvival/Assets/Test/Scripts/TestDestroySelf.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'AlienSurvival/Assets/Test/Scripts/TestDestroySelf.cs') diff --git a/AlienSurvival/Assets/Test/Scripts/TestDestroySelf.cs b/AlienSurvival/Assets/Test/Scripts/TestDestroySelf.cs index 0ab48da..1ccd825 100644 --- a/AlienSurvival/Assets/Test/Scripts/TestDestroySelf.cs +++ b/AlienSurvival/Assets/Test/Scripts/TestDestroySelf.cs @@ -6,10 +6,18 @@ public class TestDestroySelf : MonoBehaviour { public float lifeTime; + public AnimationCurve alphaCurve; + + private float time; + + private SpriteRenderer sr; + void Start() { Invoke("DestroySelf", lifeTime); - } + time = 0; + sr = GetComponent(); + } void DestroySelf() { @@ -17,4 +25,14 @@ public class TestDestroySelf : MonoBehaviour Destroy(this.gameObject); } + void Update() + { + time += Time.deltaTime; + + Color c = sr.color; + c.a = alphaCurve.Evaluate(time / lifeTime); + + sr.color = c; + } + } -- cgit v1.1-26-g67d0