InvokeUnSpawnHandler() static private method

static private InvokeUnSpawnHandler ( NetworkHash128 assetId, GameObject obj ) : bool
assetId NetworkHash128
obj UnityEngine.GameObject
return bool
Ejemplo n.º 1
0
 private static void OnObjectDestroy(NetworkMessage netMsg)
 {
     netMsg.ReadMessage(s_ObjectDestroyMessage);
     if (LogFilter.logDebug)
     {
         Debug.Log("ClientScene::OnObjDestroy netId:" + s_ObjectDestroyMessage.netId);
     }
     if (s_NetworkScene.GetNetworkIdentity(s_ObjectDestroyMessage.netId, out NetworkIdentity uv))
     {
         uv.OnNetworkDestroy();
         if (!NetworkScene.InvokeUnSpawnHandler(uv.assetId, uv.gameObject))
         {
             if (uv.sceneId.IsEmpty())
             {
                 Object.Destroy(uv.gameObject);
             }
             else
             {
                 uv.gameObject.SetActive(value: false);
                 s_SpawnableObjects[uv.sceneId] = uv;
             }
         }
         s_NetworkScene.RemoveLocalObject(s_ObjectDestroyMessage.netId);
     }
     else if (LogFilter.logDebug)
     {
         Debug.LogWarning("Did not find target for destroy message for " + s_ObjectDestroyMessage.netId);
     }
 }
Ejemplo n.º 2
0
        private static void OnObjectDestroy(NetworkMessage netMsg)
        {
            NetworkIdentity identity;

            netMsg.ReadMessage <ObjectDestroyMessage>(s_ObjectDestroyMessage);
            if (LogFilter.logDebug)
            {
                Debug.Log("ClientScene::OnObjDestroy netId:" + s_ObjectDestroyMessage.netId);
            }
            if (s_NetworkScene.GetNetworkIdentity(s_ObjectDestroyMessage.netId, out identity))
            {
                NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, 1, GetStringForAssetId(identity.assetId), 1);
                identity.OnNetworkDestroy();
                if (!NetworkScene.InvokeUnSpawnHandler(identity.assetId, identity.gameObject))
                {
                    if (identity.sceneId.IsEmpty())
                    {
                        UnityEngine.Object.Destroy(identity.gameObject);
                    }
                    else
                    {
                        identity.gameObject.SetActive(false);
                        s_SpawnableObjects[identity.sceneId] = identity;
                    }
                }
                s_NetworkScene.RemoveLocalObject(s_ObjectDestroyMessage.netId);
                identity.MarkForReset();
            }
            else if (LogFilter.logDebug)
            {
                Debug.LogWarning("Did not find target for destroy message for " + s_ObjectDestroyMessage.netId);
            }
        }
Ejemplo n.º 3
0
        private static void OnObjectDestroy(NetworkMessage netMsg)
        {
            netMsg.ReadMessage <ObjectDestroyMessage>(ClientScene.s_ObjectDestroyMessage);
            if (LogFilter.logDebug)
            {
                Debug.Log("ClientScene::OnObjDestroy netId:" + ClientScene.s_ObjectDestroyMessage.netId);
            }
            NetworkIdentity networkIdentity;

            if (ClientScene.s_NetworkScene.GetNetworkIdentity(ClientScene.s_ObjectDestroyMessage.netId, out networkIdentity))
            {
                networkIdentity.OnNetworkDestroy();
                if (!NetworkScene.InvokeUnSpawnHandler(networkIdentity.assetId, networkIdentity.gameObject))
                {
                    if (networkIdentity.sceneId.IsEmpty())
                    {
                        Object.Destroy(networkIdentity.gameObject);
                    }
                    else
                    {
                        networkIdentity.gameObject.SetActive(false);
                        ClientScene.s_SpawnableObjects[networkIdentity.sceneId] = networkIdentity;
                    }
                }
                ClientScene.s_NetworkScene.RemoveLocalObject(ClientScene.s_ObjectDestroyMessage.netId);
                networkIdentity.MarkForReset();
            }
            else if (LogFilter.logDebug)
            {
                Debug.LogWarning("Did not find target for destroy message for " + ClientScene.s_ObjectDestroyMessage.netId);
            }
        }
        static void OnObjectDestroy(NetworkMessage netMsg)
        {
            ObjectDestroyMessage msg = new ObjectDestroyMessage();

            netMsg.ReadMessage(msg);
            if (LogFilter.logDebug)
            {
                Debug.Log("ClientScene::OnObjDestroy netId:" + msg.netId);
            }

            NetworkIdentity localObject;

            if (s_NetworkScene.GetNetworkIdentity(msg.netId, out localObject))
            {
#if UNITY_EDITOR
                UnityEditor.NetworkDetailStats.IncrementStat(
                    UnityEditor.NetworkDetailStats.NetworkDirection.Incoming,
                    (short)MsgType.ObjectDestroy, GetStringForAssetId(localObject.assetId), 1);
#endif
                localObject.OnNetworkDestroy();

                if (!NetworkScene.InvokeUnSpawnHandler(localObject.assetId, localObject.gameObject))
                {
                    // default handling
                    if (localObject.sceneId.IsEmpty())
                    {
                        Object.Destroy(localObject.gameObject);
                    }
                    else
                    {
                        // scene object.. disable it in scene instead of destroying
                        localObject.gameObject.SetActive(false);
                        s_SpawnableObjects[localObject.sceneId] = localObject;
                    }
                }
                s_NetworkScene.RemoveLocalObject(msg.netId);
                localObject.MarkForReset();
            }
            else
            {
                if (LogFilter.logDebug)
                {
                    Debug.LogWarning("Did not find target for destroy message for " + msg.netId);
                }
            }
        }
Ejemplo n.º 5
0
 internal void DestroyAllClientObjects()
 {
     foreach (NetworkInstanceId key in this.m_LocalObjects.Keys)
     {
         NetworkIdentity networkIdentity = this.m_LocalObjects[key];
         if (networkIdentity != null && networkIdentity.gameObject != null)
         {
             if (!NetworkScene.InvokeUnSpawnHandler(networkIdentity.assetId, networkIdentity.gameObject))
             {
                 if (networkIdentity.sceneId.IsEmpty())
                 {
                     Object.Destroy(networkIdentity.gameObject);
                 }
                 else
                 {
                     networkIdentity.MarkForReset();
                     networkIdentity.gameObject.SetActive(false);
                 }
             }
         }
     }
     this.ClearLocalObjects();
 }
Ejemplo n.º 6
0
        private static void OnObjectDestroy(NetworkMessage netMsg)
        {
            netMsg.ReadMessage <ObjectDestroyMessage>(ClientScene.s_ObjectDestroyMessage);
            if (LogFilter.logDebug)
            {
                Debug.Log((object)("ClientScene::OnObjDestroy netId:" + (object)ClientScene.s_ObjectDestroyMessage.netId));
            }
            NetworkIdentity uv;

            if (ClientScene.s_NetworkScene.GetNetworkIdentity(ClientScene.s_ObjectDestroyMessage.netId, out uv))
            {
                NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, (short)1, ClientScene.GetStringForAssetId(uv.assetId), 1);
                uv.OnNetworkDestroy();
                if (!NetworkScene.InvokeUnSpawnHandler(uv.assetId, uv.gameObject))
                {
                    if (uv.sceneId.IsEmpty())
                    {
                        Object.Destroy((Object)uv.gameObject);
                    }
                    else
                    {
                        uv.gameObject.SetActive(false);
                        ClientScene.s_SpawnableObjects[uv.sceneId] = uv;
                    }
                }
                ClientScene.s_NetworkScene.RemoveLocalObject(ClientScene.s_ObjectDestroyMessage.netId);
            }
            else
            {
                if (!LogFilter.logDebug)
                {
                    return;
                }
                Debug.LogWarning((object)("Did not find target for destroy message for " + (object)ClientScene.s_ObjectDestroyMessage.netId));
            }
        }