From 79ff94365b572d0e64ba945dcef2641ee508faa7 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 6 Nov 2020 20:41:04 +0800 Subject: =?UTF-8?q?*=E7=A9=BA=E4=B8=AD=E6=94=BB=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/Effects/AfterImage/AfterImagePool.cs | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'Assets/Scripts/Effects/AfterImage/AfterImagePool.cs') diff --git a/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs b/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs index 8b32fe38..38d3488d 100644 --- a/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs +++ b/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs @@ -4,9 +4,10 @@ using UnityEngine; public class AfterImagePool : MonoBehaviour { - - //public CharacterControl myCharacterControl; - public GameObject targetObject; //Set these manually to the character object you're copying + public static AfterImagePool Instance; + + //public CharacterControl myCharacterControl; + public GameObject targetObject; //Set these manually to the character object you're copying public Animator targetAnimator; //Set these manually to the character object you're copying public GameObject prefab; //This is the prefab you made in the scene. It's a parent transform with an animator and AfterImage script on it, with Armature and SkinnedMeshRenderer children public int poolSize = 10; @@ -16,6 +17,8 @@ public class AfterImagePool : MonoBehaviour public int time = 0; + private bool isActive = false; + // Use this for initialization void Start() { @@ -32,13 +35,17 @@ public class AfterImagePool : MonoBehaviour afterImages.Add(nextAfterImage.GetComponent()); } + Instance = this; } // Update is called once per frame void Update() { + if (!isActive) + return; + time++; - if (time > interval) + if (time >= interval) { time = 0; AddAfterImage(); @@ -56,4 +63,16 @@ public class AfterImagePool : MonoBehaviour } } } + + public void Activate(bool isActive) + { + this.isActive = isActive; + time = isActive ? interval : 0; + } + + public void SetInterval(int interval) + { + this.interval = interval; + } + } \ No newline at end of file -- cgit v1.1-26-g67d0