MasterServer.OnMasterServerEvent 当主服务器事件

function OnMasterServerEvent (msEvent : MasterServerEvent) : void

Description描述

Called on clients or servers when reporting events from the MasterServer.

当从主服务器报告事件时,在客户端或服务器端调用。

Like, for example, when a host list has been received or host registration succeeded.

例如,当一个主机列表已接收或主机注册成功。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Start() {
		Network.InitializeServer(32, 25000);
	}
	void OnServerInitialized() {
		MasterServer.RegisterHost("MyGameVer1.0.0_42", "My Game Instance", "This is a comment and place to store data");
	}
	void OnMasterServerEvent(MasterServerEvent msEvent) {
		if (msEvent == MasterServerEvent.RegistrationSucceeded)
			Debug.Log("Server registered");

	}
}
function Start () {
	Network.InitializeServer(32, 25000);
}

function OnServerInitialized() {
	MasterServer.RegisterHost( "MyGameVer1.0.0_42"
		, "My Game Instance"
		, "This is a comment and place to store data");
}

function OnMasterServerEvent(msEvent: MasterServerEvent) {
	if (msEvent == MasterServerEvent.RegistrationSucceeded) {
		Debug.Log("Server registered");
	}
}
最后修改:2011年9月16日 Friday 15:02

本脚本参考基于Unity 3.4.1f5

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