Network.InitializeServer 初始化服务器

static function InitializeServer (connections : int, listenPort : int, useNat : bool) : NetworkConnectionError

Description描述

Initialize the server.

初始化服务器。

connections is the number of allowed incoming connections / number of players allowed in the game. listenPort is the port number we want to listen to. useNat sets the NAT punchthrough functionality. If you want this server to be able to accept connections using NAT punchthrough, using the facilitator, set this to true.

connections是允许的入站连接或玩家的数量,listenPort是要监听的端口,useNat设置NAT穿透功能。如果你想要这个服务器能够接受连接使用NAT穿透,使用facilitator,设置这个为true。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void LaunchServer() {
		Network.incomingPassword = "HolyMoly";
		bool useNat = !Network.HavePublicAddress();
		Network.InitializeServer(32, 25000, useNat);
	}
}
function LaunchServer () {
	Network.incomingPassword = "HolyMoly";
	var useNat = !Network.HavePublicAddress();
	Network.InitializeServer(32, 25000, useNat);
}
最后修改:2011年4月2日 Saturday 16:38

本脚本参考基于Unity 3.4.1f5

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