Version: 2021.3

MonoBehaviour.OnPlayerDisconnected(NetworkPlayer)

切换到手册

描述

每当有玩家与服务器断开连接,就在服务器上调用。

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); } }