只有赋值,调用,递增,递减和新对象表达式才能用作语句
我不确定这个错误是什么。
代码中没有其他语法错误
using UnityEngine;
using System.Collections;
public class NetworkManager : MonoBehaviour {
// Use this for initialization
void Start () {
PhotonNetwork.ConnectUsingSettings("1.0");
}
private const string roomName = "RoomName";
private RoomInfo[] roomsList;
void OnGUI()
{
if (!PhotonNetwork.connected)
{
GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
}
else if (PhotonNetwork.room == null)
{
// Create Room
if (GUI.Button(new Rect(100, 100, 250, 100), "Start Server"))
PhotonNetwork.CreateRoom(roomName + Guid.NewGuid().ToString("N"), true, true, 5);
// Join Room
if (roomsList != null)
{
for (int i = 0; i < roomsList.Length; i++)
{
if (GUI.Button(new Rect(100, 250 + (110 * i), 250, 100), "Join " + roomsList[i].name))
PhotonNetwork.JoinRoom(roomsList[i].name);
}
}
}
}
void OnReceivedRoomListUpdate()
{
roomsList = PhotonNetwork.GetRoomList();
}
void OnJoinedRoom()
{
Debug.Log("Connected to Room");
}
}
答案 0 :(得分:0)
应该是roomsList.GetLength(0)
。见here
答案 1 :(得分:0)
尝试
int i = 0;
foreach (RoomInfo game in PhotonNetwork.GetRoomList())
{
if (GUI.Button(new Rect(5, (40 * (i + 2)) + 10, Screen.width - 10, 40), "Join" + game.name, _skin.button))
{
PhotonNetwork.JoinRoom(game.name);
}
i++;
}