MonoBehaviour.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年1月2日 Sunday 18:50

本脚本参考基于Unity 3.4.1f5

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