在Unity中的局域网多人游戏的问题

我正试图学习如何在Unity中制作一个离线的局域网多人游戏。

所以举个例子,我做了一些可以发送短信并制作立方体XD的东西

现在这是我的问题:

在这里输入图像描述

(当我发送消息时,尝试连接到服务器,或者当我尝试创建一个多维数据集时,我应该先点击另一个窗口!)

startserver的:

using UnityEngine; using System.Collections; public class StartServer : MonoBehaviour { public Transform Taghsimobj; public Transform Makan; public Transform CubeOBJ; public string MSG; public string ResMsg; void Ress (string inres) { ResMsg = inres; } void OnGUI () { if (Network.peerType == NetworkPeerType.Disconnected) { if (GUILayout.Button ("StartServer")) { Network.InitializeServer(10, 25000); } if (GUILayout.Button ("Connect")) { Network.Connect ("192.168.1.101", 25000); } } else { if (GUILayout.Button ("CreatCube")) { Network.Instantiate (CubeOBJ, Makan.transform.position, Makan.transform.rotation, 0); } if (GUILayout.Button ("CreatChat")) { Network.Instantiate (Taghsimobj, this.transform.position, this.transform.rotation, 0); } if (GUILayout.Button ("SendMessage")) { GameObject.Find ("GameObject(Clone)").GetComponent<NetworkView>().RPC ("ResText", RPCMode.All, MSG); } MSG=GUILayout.TextField(MSG); GUILayout.Box (ResMsg); } } } 

taghsim:

  using UnityEngine; using System.Collections; public class Taghsim : MonoBehaviour { void Start () { } [RPC] void ResText (string ResIn) { GameObject.Find ("Main Camera").SendMessage ("Ress", ResIn); } } 

Solutions Collecting From Web of "在Unity中的局域网多人游戏的问题"