public void EnableShields() { if (!IonicShield.activeSelf) { IonicShield.SetActive(true); YogicShield.SetActive(true); StartCoroutine(FadeShieldIn()); StartCoroutine(DisableShields()); } }
IEnumerator FadeShieldIn() { for (float t = 0.0f; t < 1f; t += (Time.deltaTime * 3)) { Color newColor = new Color(1, 1, 1, Mathf.Lerp(0, 1, t)); IonicShield.GetComponent <SpriteRenderer>().color = newColor; YogicShield.GetComponent <SpriteRenderer>().color = newColor; yield return(null); } }