NetworkServer: ValidateSceneObject renamed to IsSceneObject - that's what it checks

This commit is contained in:
vis2k 2022-09-17 16:58:13 +08:00
parent 0fbf400697
commit 4654a281f3
2 changed files with 8 additions and 8 deletions

View File

@ -1141,7 +1141,7 @@ public static void Spawn(GameObject obj, Guid assetId, NetworkConnection ownerCo
}
// TODO merge with ConsiderForSpawning on client
internal static bool ValidateSceneObject(NetworkIdentity identity)
internal static bool IsSceneObject(NetworkIdentity identity)
{
if (identity.gameObject.hideFlags == HideFlags.NotEditable ||
identity.gameObject.hideFlags == HideFlags.HideAndDontSave)
@ -1173,7 +1173,7 @@ public static bool SpawnObjects()
// first pass: activate all scene objects
foreach (NetworkIdentity identity in identities)
{
if (ValidateSceneObject(identity))
if (IsSceneObject(identity))
{
// Debug.Log($"SpawnObjects sceneId:{identity.sceneId:X} name:{identity.gameObject.name}");
identity.gameObject.SetActive(true);
@ -1193,7 +1193,7 @@ public static bool SpawnObjects()
// second pass: spawn all scene objects
foreach (NetworkIdentity identity in identities)
{
if (ValidateSceneObject(identity))
if (IsSceneObject(identity))
// pass connection so that authority is not lost when server loads a scene
// https://github.com/vis2k/Mirror/pull/2987
Spawn(identity.gameObject, identity.connectionToClient);

View File

@ -1025,25 +1025,25 @@ public void HideForConnection()
}
[Test]
public void ValidateSceneObject()
public void IsSceneObject()
{
// create a gameobject and networkidentity
CreateNetworked(out GameObject go, out NetworkIdentity identity);
identity.sceneId = 42;
// should be valid as long as it has a sceneId
Assert.That(NetworkServer.ValidateSceneObject(identity), Is.True);
Assert.That(NetworkServer.IsSceneObject(identity), Is.True);
// shouldn't be valid with 0 sceneID
identity.sceneId = 0;
Assert.That(NetworkServer.ValidateSceneObject(identity), Is.False);
Assert.That(NetworkServer.IsSceneObject(identity), Is.False);
identity.sceneId = 42;
// shouldn't be valid for certain hide flags
go.hideFlags = HideFlags.NotEditable;
Assert.That(NetworkServer.ValidateSceneObject(identity), Is.False);
Assert.That(NetworkServer.IsSceneObject(identity), Is.False);
go.hideFlags = HideFlags.HideAndDontSave;
Assert.That(NetworkServer.ValidateSceneObject(identity), Is.False);
Assert.That(NetworkServer.IsSceneObject(identity), Is.False);
}
[Test]