MasterServer.updateRate 更新率

static var updateRate : int

Description描述

Set the minimum update rate for master server host information update.

设置主服务器主机信息更新的最小更新率。

Normally host updates are only sent if something in the host information has changed (like connected players). The update rate defines the minimum amount of time which may elapse between host updates. The default value is 60 seconds minimum update rate (where a check is made for changes). So if one host update is sent and then some field changes 10 seconds later then the update will possibly sent 50 seconds later (at the next change check). If this is set to 0 then no updates are sent, only initial registration information.

通常主机更新只在主机信息改变的时候被发送(比如说,连接玩家)。更新率定义主机更新所用的最小的时间量。它的默认值是60秒(即每60秒检测一次改变)。所以如果一次主机更新被发送,然后10秒钟之后一些变量被改变,那么这个更新将在50秒之后被发送(在下一次改变检查的时候)。如果它被设置为0,那么将不发送更新,只有最初的注册信息。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void StartServer() {
		Network.InitializeServer(32, 25002);
		MasterServer.updateRate = 0;
		MasterServer.RegisterHost("MyUniqueGameType", "JohnDoes game", "l33t game for all");
	}
}
function StartServer() {
	Network.InitializeServer(32, 25002);
	// No host information updates after initial registration
	//在最初注册之后,没有主机信息更新。
	MasterServer.updateRate = 0;
	MasterServer.RegisterHost("MyUniqueGameType", "JohnDoes game", "l33t game for all");
}
最后修改:2011年1月4日 Tuesday 15:43

本脚本参考基于Unity 3.4.1f5

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