SanAndreasUnity/Assets/Scripts/UI/ChatInputController.cs
2020-05-31 19:09:54 +02:00

32 lines
666 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace SanAndreasUnity.UI
{
public class ChatInputController : MonoBehaviour
{
public InputField inputField;
public Button sendButton;
void Start()
{
this.sendButton.onClick.AddListener(() => SendChatMessage(this.inputField.text));
}
void SendChatMessage(string msg)
{
this.inputField.text = "";
if (string.IsNullOrWhiteSpace(msg))
return;
Chat.ChatManager.SendChatMessageToAllPlayersAsLocalPlayer(msg);
}
}
}