I have been trying to debunk this problem for a while now. I am fairly new to unity and networking all together. Below is my script and the errors I have been getting. It is the only script in my project and keeps throwing the error “Error building Player because scripts had compiler errors”. All the other errors only appear on the first build attempt and will disappear when built again. I have made a few other Unity projects not using the Networking class and still run into a similar problem of a single compiler error with no details. Any help or insight would be much appreciated.
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
public class connector : MonoBehaviour
{
public string connectionIP = "127.0.0.1";
public int connectionPort = 25001;
private void OnGUI()
{
if (Network.peerType == NetworkPeerType.Disconnected)
{
GUI.Label(new Rect(10, 10, 300, 20), "Status: Disconnected");
if (GUI.Button(new Rect(10, 30, 120, 20), "Client Connect"))
{
Network.Connect(connectionIP, connectionPort);
}
if (GUI.Button(new Rect(10, 50, 120, 20), "Initialize Server"))
{
Network.InitializeServer(32, connectionPort, false);
}
}
else if (Network.peerType == NetworkPeerType.Client)
{
GUI.Label(new Rect(10, 10, 300, 20), "Status Connected as Server");
if (GUI.Button(new Rect(10, 30, 120, 20), "Disconnect"))
{
Network.Disconnect(200);
}
}
}
}