UnityEngine.Networking.NetworkServer.DestroyPlayersForConnection C# (CSharp) Метод

DestroyPlayersForConnection() публичный статический Метод

This destroys all the player objects associated with a NetworkConnections on a server.

public static DestroyPlayersForConnection ( NetworkConnection conn ) : void
conn NetworkConnection The connections object to clean up for.
Результат void
        public static void DestroyPlayersForConnection(NetworkConnection conn)
        {
            if (conn.playerControllers.Count == 0)
            {
                if (LogFilter.logWarn)
                {
                    Debug.LogWarning("Empty player list given to NetworkServer.Destroy(), nothing to do.");
                }
            }
            else
            {
                if (conn.clientOwnedObjects != null)
                {
                    HashSet<NetworkInstanceId> set = new HashSet<NetworkInstanceId>(conn.clientOwnedObjects);
                    foreach (NetworkInstanceId id in set)
                    {
                        GameObject obj2 = FindLocalObject(id);
                        if (obj2 != null)
                        {
                            DestroyObject(obj2);
                        }
                    }
                }
                for (int i = 0; i < conn.playerControllers.Count; i++)
                {
                    PlayerController controller = conn.playerControllers[i];
                    if (controller.IsValid)
                    {
                        if (controller.unetView != null)
                        {
                            DestroyObject(controller.unetView, true);
                        }
                        controller.gameObject = null;
                    }
                }
                conn.playerControllers.Clear();
            }
        }