public int connections = 10; //
public int listenPort = 8899; //
public bool UseNat = false; //
public string ip = "127.0.0.1";
public GameObject PlayerPrefab;
public void OnGUI()
{
if (Network.peerType == NetworkPeerType.Disconnected)
{
if (GUILayout.Button(" "))
{
//
NetworkConnectionError error = Network.InitializeServer(connections, listenPort, UseNat);
print("aha");
}
if (GUILayout.Button(" "))
{
//
NetworkConnectionError error = Network.Connect(ip, listenPort);
}
}
else
if(Network.peerType == NetworkPeerType.Server)
{
GUILayout.Label(" ");
}
else
if(Network.peerType == NetworkPeerType.Client)
{
GUILayout.Label(" ");
}
}
//
void OnServerInitialized()
{
print("server ");
//NetWork.Player
int Group = int.Parse(Network.player + "");
Network.Instantiate(PlayerPrefab, new Vector3(0,10,0),Quaternion.identity,Group);
}
void OnPlayerConnected(NetworkPlayer player)
{
print(" Index Number:" + player);
}
//
void OnConnectedToServer()
{
print(" !");
}
~~~ this is (ruoji)