Exemplo n.º 1
0
        private void UnSpawn(NetworkIdentity identity)
        {
            logger.Assert(!Client.IsLocalClient, "UnSpawn should not be called in host mode");
            // it is useful to remove authority when destroying the object
            // this can be useful to clean up stuff after a local player is destroyed
            // call before StopClient, but dont reset the HasAuthority bool, people might want to use HasAuthority from stopclient or destroy
            if (identity.HasAuthority)
            {
                identity.CallStopAuthority();
            }

            identity.StopClient();

            if (_unspawnHandlers.TryGetValue(identity.PrefabHash, out var handler) && handler != null)
            {
                handler(identity);
            }
            else if (!identity.IsSceneObject)
            {
                Destroy(identity.gameObject);
            }
            else
            {
                identity.NetworkReset();
                identity.gameObject.SetActive(false);
                spawnableObjects[identity.SceneId] = identity;
            }

            Client.World.RemoveIdentity(identity);
        }
Exemplo n.º 2
0
        public void OnStopClient()
        {
            UnityAction mockCallback = Substitute.For <UnityAction>();

            identity.OnStopClient.AddListener(mockCallback);

            identity.StopClient();

            mockCallback.Received().Invoke();
        }
Exemplo n.º 3
0
        void UnSpawn(NetworkIdentity identity)
        {
            identity.StopClient();
            if (unspawnHandlers.TryGetValue(identity.PrefabHash, out UnSpawnDelegate handler) && handler != null)
            {
                handler(identity);
            }
            else if (!identity.IsSceneObject)
            {
                Destroy(identity.gameObject);
            }
            else
            {
                identity.NetworkReset();
                identity.gameObject.SetActive(false);
                spawnableObjects[identity.SceneId] = identity;
            }

            Client.World.RemoveIdentity(identity);
        }
Exemplo n.º 4
0
        void UnSpawn(NetworkIdentity identity)
        {
            Guid assetId = identity.AssetId;

            identity.StopClient();
            if (unspawnHandlers.TryGetValue(assetId, out UnSpawnDelegate handler) && handler != null)
            {
                handler(identity);
            }
            else if (identity.sceneId == 0)
            {
                Destroy(identity.gameObject);
            }
            else
            {
                identity.Reset();
                identity.gameObject.SetActive(false);
                spawnableObjects[identity.sceneId] = identity;
            }

            Client.World.RemoveIdentity(identity);
        }