So I’m working on a mostly text based game, and its almost done… well if not being able to play it in network can be counted as almost than yeah…
I just need to send text from text box on a server to a label on a client, and vice versa. I’ve been trying to find something relevant to my problem but nothing came up.
Here’s my code:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class NetTesting : MonoBehaviour {
public string connectionIP = "127.0.0.1";
public int connectionPort = 25001;
public Text status;
public void ClientConnect()
{
Network.Connect("127.0.0.1", 25001);
}
public void Host()
{
Network.InitializeServer(32, connectionPort, false);
}
void Update()
{
if (Network.isServer)
{
status.text = "You are the host";
}
if (Network.peerType == NetworkPeerType.Client)
{
status.text = "You are the client";
}
if (Network.peerType == NetworkPeerType.Disconnected)
{
status.text = "Disconnected";
}
}
}
I won’t even bother posting all the things I’ve tried to make it work.
Thank you people!