private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Player")) { string t = ui.Read(TipIndex); if (t != "") { TipShower.GetComponentInChildren <Text>().text = t; TipShower.SetActive(true); StartCoroutine("Fade"); } } }
IEnumerator Fade() { if (IsPlaying) { IsPlaying = false; yield return(null); } for (int i = 0; i < count; i++) { if (ui.CurrentIndex != TipIndex) { break; } TipShower.GetComponentInChildren <Text>().color = new Color(0, 0, 0, (count - i) / (float)count); TipShower.GetComponentInChildren <Image>().color = new Color(1, 1, 1, (count - i) / (float)count); yield return(new WaitForSeconds(0.2f)); } if (ui.CurrentIndex == TipIndex) { TipShower.SetActive(false); } yield return(null); }