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); } }
private static void OnLocalClientObjectDestroy(NetworkMessage netMsg) { netMsg.ReadMessage <ObjectDestroyMessage>(s_ObjectDestroyMessage); if (LogFilter.logDebug) { Debug.Log("ClientScene::OnLocalObjectObjDestroy netId:" + s_ObjectDestroyMessage.netId); } s_NetworkScene.RemoveLocalObject(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); } } }