Legenda.cs
915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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<Animation>();
LEGENDA = gameObject.GetComponent<Text>();
}
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);
}
}