本文整理汇总了C#中NetworkManager.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkManager.Connect方法的具体用法?C# NetworkManager.Connect怎么用?C# NetworkManager.Connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkManager
的用法示例。
在下文中一共展示了NetworkManager.Connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
NetworkManager netMan = new NetworkManager();
Client client = new Client();
netMan.Register(client);
Console.Write("Enter ip to connect to: ");
string ipAddr = Console.ReadLine();
if (!netMan.Connect(ipAddr))
{
Console.WriteLine("Failed to connect to {0}", ipAddr);
netMan.Disconnect();
return;
}
string msg = null;
do
{
Console.Write("Enter message to send to server: ");
msg = Console.ReadLine();
netMan.Send(ipAddr, Encoding.ASCII.GetBytes(msg));
} while (!msg.Equals("exit"));
netMan.Disconnect();
}
示例2: LateStart
void LateStart()
{
_network = GameObject.FindGameObjectWithTag("GameController").GetComponent<NetworkManager>();
TextBox userName = new TextBox("user", new Rect(XCentre - 50, YCentre - 200, 100, 50));
TextBox password = new TextBox("password", new Rect(XCentre - 50, YCentre - 150, 100, 50));
Button b = new Button("Connect", XCentre - 50, YCentre - 100);
b.OnClick += delegate(Button sender)
{
_network.Connect(userName.Text, password.Text);
userName.Enabled = false;
password.Enabled = false;
b.Enabled = false;
};
_network.OnShowCharSelect += _network_OnShowCharSelect;
_network.OnEnterWorld += _network_OnEnterWorld;
bStarted = true;
}
示例3: Start
void Start()
{
nm = new NetworkManager();
nm.Connect();
InterEquipe.SetActive(true);
}