mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Update ClientScene.cs (#2250)
* Update ClientScene.cs Improving logging - making sure sceneId is always hex - only logging "Client spawn for ..." if it was successful * Update ClientSceneTests_OnSpawn.cs
This commit is contained in:
parent
833c329ab2
commit
7580e9a6f5
@ -782,7 +782,7 @@ internal static void ApplySpawnPayload(NetworkIdentity identity, SpawnMessage ms
|
|||||||
|
|
||||||
internal static void OnSpawn(SpawnMessage msg)
|
internal static void OnSpawn(SpawnMessage msg)
|
||||||
{
|
{
|
||||||
if (logger.LogEnabled()) logger.Log($"Client spawn handler instantiating netId={msg.netId} assetID={msg.assetId} sceneId={msg.sceneId} pos={msg.position}");
|
if (logger.LogEnabled()) logger.Log($"Client spawn handler instantiating netId={msg.netId} assetID={msg.assetId} sceneId={msg.sceneId:X} pos={msg.position}");
|
||||||
|
|
||||||
if (FindOrSpawnObject(msg, out NetworkIdentity identity))
|
if (FindOrSpawnObject(msg, out NetworkIdentity identity))
|
||||||
{
|
{
|
||||||
@ -814,7 +814,7 @@ internal static bool FindOrSpawnObject(SpawnMessage msg, out NetworkIdentity ide
|
|||||||
|
|
||||||
if (identity == null)
|
if (identity == null)
|
||||||
{
|
{
|
||||||
logger.LogError($"Could not spawn assetId={msg.assetId} scene={msg.sceneId} netId={msg.netId}");
|
logger.LogError($"Could not spawn assetId={msg.assetId} scene={msg.sceneId:X} netId={msg.netId}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,11 +870,15 @@ static NetworkIdentity SpawnSceneObject(SpawnMessage msg)
|
|||||||
if (logger.LogEnabled())
|
if (logger.LogEnabled())
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<ulong, NetworkIdentity> kvp in spawnableObjects)
|
foreach (KeyValuePair<ulong, NetworkIdentity> kvp in spawnableObjects)
|
||||||
logger.Log("Spawnable: SceneId=" + kvp.Key + " name=" + kvp.Value.name);
|
logger.Log($"Spawnable: SceneId={kvp.Key:X} name={kvp.Value.name}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// only log this when successful
|
||||||
|
if (logger.LogEnabled()) logger.Log($"Client spawn for [netId:{msg.netId}] [sceneId:{msg.sceneId:X}] obj:{identity}");
|
||||||
|
}
|
||||||
|
|
||||||
if (logger.LogEnabled()) logger.Log("Client spawn for [netId:" + msg.netId + "] [sceneId:" + msg.sceneId + "] obj:" + identity);
|
|
||||||
return identity;
|
return identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ public void FindOrSpawnObject_ErrorWhenPrefabInNullInDictionary()
|
|||||||
prefabs.Add(validPrefabGuid, null);
|
prefabs.Add(validPrefabGuid, null);
|
||||||
|
|
||||||
LogAssert.Expect(LogType.Error, $"Failed to spawn server object, did you forget to add it to the NetworkManager? assetId={msg.assetId} netId={msg.netId}");
|
LogAssert.Expect(LogType.Error, $"Failed to spawn server object, did you forget to add it to the NetworkManager? assetId={msg.assetId} netId={msg.netId}");
|
||||||
LogAssert.Expect(LogType.Error, $"Could not spawn assetId={msg.assetId} scene={msg.sceneId} netId={msg.netId}");
|
LogAssert.Expect(LogType.Error, $"Could not spawn assetId={msg.assetId} scene={msg.sceneId:X} netId={msg.netId}");
|
||||||
bool success = ClientScene.FindOrSpawnObject(msg, out NetworkIdentity networkIdentity);
|
bool success = ClientScene.FindOrSpawnObject(msg, out NetworkIdentity networkIdentity);
|
||||||
|
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ public void FindOrSpawnObject_ErrorWhenSpawnHanlderReturnsNull()
|
|||||||
});
|
});
|
||||||
|
|
||||||
LogAssert.Expect(LogType.Error, $"Spawn Handler returned null, Handler assetId '{msg.assetId}'");
|
LogAssert.Expect(LogType.Error, $"Spawn Handler returned null, Handler assetId '{msg.assetId}'");
|
||||||
LogAssert.Expect(LogType.Error, $"Could not spawn assetId={msg.assetId} scene={msg.sceneId} netId={msg.netId}");
|
LogAssert.Expect(LogType.Error, $"Could not spawn assetId={msg.assetId} scene={msg.sceneId:X} netId={msg.netId}");
|
||||||
bool success = ClientScene.FindOrSpawnObject(msg, out NetworkIdentity networkIdentity);
|
bool success = ClientScene.FindOrSpawnObject(msg, out NetworkIdentity networkIdentity);
|
||||||
|
|
||||||
Assert.IsFalse(success);
|
Assert.IsFalse(success);
|
||||||
@ -255,7 +255,7 @@ public void FindOrSpawnObject_ErrorWhenSpawnHanlderReturnsWithoutNetworkIdentity
|
|||||||
});
|
});
|
||||||
|
|
||||||
LogAssert.Expect(LogType.Error, $"Object Spawned by handler did not have a NetworkIdentity, Handler assetId '{validPrefabGuid}'");
|
LogAssert.Expect(LogType.Error, $"Object Spawned by handler did not have a NetworkIdentity, Handler assetId '{validPrefabGuid}'");
|
||||||
LogAssert.Expect(LogType.Error, $"Could not spawn assetId={msg.assetId} scene={msg.sceneId} netId={msg.netId}");
|
LogAssert.Expect(LogType.Error, $"Could not spawn assetId={msg.assetId} scene={msg.sceneId:X} netId={msg.netId}");
|
||||||
bool success = ClientScene.FindOrSpawnObject(msg, out NetworkIdentity networkIdentity);
|
bool success = ClientScene.FindOrSpawnObject(msg, out NetworkIdentity networkIdentity);
|
||||||
|
|
||||||
Assert.IsFalse(success);
|
Assert.IsFalse(success);
|
||||||
@ -330,7 +330,7 @@ public void FindOrSpawnObject_ErrorWhenSceneIdIsNotInSpawnableObjectsDictionary(
|
|||||||
};
|
};
|
||||||
|
|
||||||
LogAssert.Expect(LogType.Error, $"Spawn scene object not found for {msg.sceneId:X} SpawnableObjects.Count={spawnableObjects.Count}");
|
LogAssert.Expect(LogType.Error, $"Spawn scene object not found for {msg.sceneId:X} SpawnableObjects.Count={spawnableObjects.Count}");
|
||||||
LogAssert.Expect(LogType.Error, $"Could not spawn assetId={msg.assetId} scene={msg.sceneId} netId={msg.netId}");
|
LogAssert.Expect(LogType.Error, $"Could not spawn assetId={msg.assetId} scene={msg.sceneId:X} netId={msg.netId}");
|
||||||
bool success = ClientScene.FindOrSpawnObject(msg, out NetworkIdentity networkIdentity);
|
bool success = ClientScene.FindOrSpawnObject(msg, out NetworkIdentity networkIdentity);
|
||||||
|
|
||||||
Assert.IsFalse(success);
|
Assert.IsFalse(success);
|
||||||
|
Loading…
Reference in New Issue
Block a user