using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using NeonTea.Quakeball.Net.Peers; namespace NeonTea.Quakeball.Net { public class CanvasInput : MonoBehaviour, PeerMessageListener { public Button Host; public Button Join; public Button Stop; public InputField HostAddr; public InputField Port; public Text TextField; private static List Stuff = new List(); void Start() { Host.onClick.AddListener(() => { Net.Singleton.StartServer("0.0.0.0", 8080, this); }); Join.onClick.AddListener(() => { Net.Singleton.StartClient("127.0.0.1", 8080, this); }); Stop.onClick.AddListener(() => { Net.Singleton.Stop(); }); } void Update() { TextField.text = string.Join("\n", Stuff.ToArray()); } public void Message(string text) { Stuff.Add(text); Debug.Log(string.Join(", ", Stuff.ToArray())); } } }