using UnityEngine; using System.Collections; using UnityEngine.UI; public class Legenda : MonoBehaviour { public Text LEGENDA; GameObject ICARO; Animation COMPONENTE_ANIMADOR; void Start () { ICARO = GameObject.FindGameObjectWithTag("avatar"); COMPONENTE_ANIMADOR = ICARO.GetComponent(); LEGENDA = gameObject.GetComponent(); } void Update(){ if(COMPONENTE_ANIMADOR.isPlaying) LEGENDA.text = GetCurrentPlayingAnimationClip( ); } string GetCurrentPlayingAnimationClip( ){ foreach( AnimationState anim in COMPONENTE_ANIMADOR ) if( COMPONENTE_ANIMADOR.IsPlaying( anim.name ) ) if( !(anim.name.Split(' ')[0].Equals("_default")) ) return anim.name.Split(' ')[0]; return null; } bool isCaptionActiveFlag = true; public void ativarLegenda( ){ isCaptionActiveFlag = !isCaptionActiveFlag; this.gameObject.SetActive(isCaptionActiveFlag); } }