using UnityEngine;
using System.Collections;
public class Network1 : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI() {
Debug.Log ("OnGUI()");
if (NetworkPeerType == NetworkPeerType.Disconnected){
if (GUI.Button (new Rect(10, 30, 120, 20), "Join a game")){
Network.Connect("127.0.0.1", 25001);
}
if (GUI.Button (new Rect(10, 50, 120, 20), "Host a game")){
Network.InitializeServer(32, 25001, false);
}
else if (Network.peerType == NetworkPeerType.Client){
GUI.Label(new Rect(10, 10, 300, 20), "Status: Connected as a Client");
if (GUI.Button (new Rect(10, 30, 120, 20), "Leave lobby")){
Network.Disconnect(200);
}
}
}
}
}
那是我的代码。它抛出此错误:
Assets / Network1.cs(15,21):错误CS0119:表达式表示type', where a
变量',value' or
方法组'预计
我现在用Google搜索了一段时间,似乎无法得到相关的答案。 任何帮助表示赞赏。
答案 0 :(得分:1)
if (NetworkPeerType == NetworkPeerType.Disconnected){
这应该是:
if (Network.peerType == NetworkPeerType.Disconnected){