每当有玩家与服务器断开连接,就在服务器上调用。
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); } }