Network.DestroyPlayerObjects

切换到手册
public static void DestroyPlayerObjects (NetworkPlayer playerID);

描述

基于属于此玩家的 viewID 销毁所有对象。

此函数只能在作为服务器运行时调用。此函数有特定用途,如清理断开连接的玩家所遗留的 联网对象。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void OnPlayerDisconnected(NetworkPlayer player) { Debug.Log("Clean up after player " + player); Network.RemoveRPCs(player); Network.DestroyPlayerObjects(player); } }