2020-08-02 02:50:01 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
2020-08-02 20:32:30 +02:00
|
|
|
|
using NeonTea.Quakeball.Net.Peers;
|
2020-08-02 02:50:01 +02:00
|
|
|
|
|
|
|
|
|
namespace NeonTea.Quakeball.Net {
|
2020-08-05 03:21:04 +02:00
|
|
|
|
public class CanvasInput : MonoBehaviour, PeerMessageListener {
|
2020-08-02 02:50:01 +02:00
|
|
|
|
public Button Host;
|
|
|
|
|
public Button Join;
|
2020-08-05 03:21:04 +02:00
|
|
|
|
public Button Stop;
|
2020-08-02 02:50:01 +02:00
|
|
|
|
public InputField HostAddr;
|
|
|
|
|
public InputField Port;
|
2020-08-05 03:21:04 +02:00
|
|
|
|
public Text TextField;
|
|
|
|
|
|
|
|
|
|
private static List<string> Stuff = new List<string>();
|
2020-08-02 02:50:01 +02:00
|
|
|
|
|
|
|
|
|
void Start() {
|
|
|
|
|
Host.onClick.AddListener(() => {
|
2020-08-05 03:21:04 +02:00
|
|
|
|
Net.Singleton.StartServer("0.0.0.0", 8080, this);
|
2020-08-02 02:50:01 +02:00
|
|
|
|
});
|
|
|
|
|
Join.onClick.AddListener(() => {
|
2020-08-05 03:21:04 +02:00
|
|
|
|
Net.Singleton.StartClient("127.0.0.1", 8080, this);
|
2020-08-02 02:50:01 +02:00
|
|
|
|
});
|
2020-08-05 03:21:04 +02:00
|
|
|
|
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()));
|
2020-08-02 02:50:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|