Network.maxConnections 最大连接数

static var maxConnections : int

Description描述

Set the maximum amount of connections/players allowed.

设置允许连接(玩家)的最大数量。

Setting it to 0 means no new connections can be made but the existing ones stay connected. Setting it to -1 means the maximum connections count is set to the same number of current open connections. In that case, if a players drops then the slot is still open for him. This cannot be set higher than the connection count given in Network.InitializeServer.

设置0,意味着没有新的连接可以被建立,但现有保持连接。设置为-1表示最大连接数,设置为与当前开发的连接数相同。在这种情况下,如果一个玩家掉线,那么这个空位还是为它开放的。这个不能设置为高于Network.InitializeServer设置的连接数。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void StartGameNow() {
		Network.maxConnections = -1;
	}
}
function StartGameNow() {
	// Don't allow any more players
	// 不允许更多玩家
	Network.maxConnections = -1;
}
最后修改:2011年4月2日 Saturday 15:31

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。