using UnityEngine; using System.Collections; using UnityEngine.UI; public class ChatWindow : MonoBehaviour { public Text text_chat; public ScrollRect scrollrect; GameObject chat_input; TchatAnim tchatAnim; string message_old; // Use this for initialization void Start () { chat_input = GameObject.Find ("tchat_complet"); tchatAnim = chat_input.GetComponent (); text_chat.text = ""; } // Update is called once per frame void Update () { if (Input.GetKeyDown ("space") && tchatAnim.message != message_old) { scrollrect.verticalNormalizedPosition = 0; text_chat.text += "perceval > " + tchatAnim.message + "\n"; message_old= tchatAnim.message; } } public void writeText(string text){ text_chat.text += text; } }