using UnityEngine;
using System.Collections;
public class Menu : MonoBehaviour {
public string IP = "127.0.0.1";
public int Port = 25001;
//public GameObject target;
void OnGUI()
{
if (Network.peerType == NetworkPeerType.Disconnected)
{
if (GUI.Button(new Rect(100, 100, 100, 25), "Start Client"))
{
Network.Connect(IP, Port);
}
if (GUI.Button(new Rect(100, 125, 100, 25), "Start Server"))
{
Network.InitializeServer(10, Port);
}
}
else
{
if (Network.peerType == NetworkPeerType.Client)
{
GUI.Label(new Rect(100, 100, 100, 25), "Client");
if(GUI.Button(new Rect(100, 125, 110, 25), "Change Color"))
{
//NetworkView networkView = new NetworkView();
//networkView.RPC("ChangeColor", RPCMode.All);
GetComponent<NetworkView>().RPC("ChangeColor", RPCMode.All);
Debug.Log("dsjakfj");
}
if (GUI.Button(new Rect(100, 150, 110, 25), "Logout"))
{
Network.Disconnect(250);
}
}
if (Network.peerType == NetworkPeerType.Server)
{
GUI.Label(new Rect(100, 100, 100, 25), "Server");
GUI.Label(new Rect(100, 125, 100, 25), "Connections:" + Network.connections.Length);
if (GUI.Button(new Rect(100, 150, 100, 25), "Logout"))
{
Network.Disconnect(250);
}
}
}
}
[RPC]
void ChangeColor()
{
this.GetComponent<Renderer>().material.color = Color.green;
}
}