Network.DestroyPlayerObjects 销毁玩家物体

static function DestroyPlayerObjects (playerID : NetworkPlayer) : void

Description描述

Destroy all the objects based on view IDs belonging to this player.

基于viewID销毁所有属于这个玩家的所有物体。

This should only be called when running as a server. It is, for example, meant to to clean up networked objects left by a disconnected player.

这个只能在服务器上调用。例如,清理一个已断开的玩家留下的网络物体。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void OnPlayerDisconnected(NetworkPlayer player) {
		Debug.Log("Clean up after player " + player);
		Network.RemoveRPCs(player);
		Network.DestroyPlayerObjects(player);
	}
}
function OnPlayerDisconnected(player: NetworkPlayer) {
	Debug.Log("Clean up after player " + player);
	Network.RemoveRPCs(player);
	Network.DestroyPlayerObjects(player);
}
最后修改:2011年4月4日 Monday 16:16

本脚本参考基于Unity 3.4.1f5

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