using UnityEngine; using UnityEngine.UI; using System.Collections; public class tchat_anim : MonoBehaviour { public Text chat; public Animator machine; public Text charac_nb; public InputField myfield; // Use this for initialization void Start () { } void Awake(){ print ("looool"); } public void MessageValidation (string message){ print ("loool"); } // Update is called once per frame void Update () { //transition vers chat_up if (chat.text.Length > 20 && machine.GetInteger("etat_chat")==0) { print ("trop long"); machine.SetInteger ("etat_chat", 1); charac_nb.text = " "; } //transition vers chat_long if (chat.text.Length > 110 && machine.GetInteger("etat_chat")==1) { print ("trop trop long"); machine.SetInteger ("etat_chat", 2); } //affichage nombre de caractère restant. if(Input.anyKey && machine.GetInteger("etat_chat")==2 ){ charac_nb.text = (myfield.characterLimit - chat.text.Length).ToString(); } //En cas de validation du message if(Input.GetKeyDown("space")){ myfield.text=""; charac_nb.text=""; print ("space pressed"); //texte long if(machine.GetInteger("etat_chat")==1 || machine.GetInteger("etat_chat")==2){ machine.SetInteger ("etat_chat", 3); } if(machine.GetInteger("etat_chat")==0){ machine.SetInteger("etat_chat",5); } } if (chat.text.Length < 20 && chat.text.Length > 0) { machine.SetInteger ("etat_chat", 0); } } }