ClientSceneTests: reuse CreateNetworked/CreateGameObject

This commit is contained in:
vis2k 2021-05-20 15:40:22 +08:00
parent 25f069065e
commit 9e73f074c9

View File

@ -245,8 +245,7 @@ public void FindOrSpawnObject_ErrorWhenSpawnHanlderReturnsWithoutNetworkIdentity
spawnHandlers.Add(validPrefabGuid, (x) => spawnHandlers.Add(validPrefabGuid, (x) =>
{ {
GameObject go = new GameObject("testObj"); CreateGameObject(out GameObject go);
_createdObjects.Add(go);
return go; return go;
}); });
@ -368,15 +367,13 @@ public void ApplyPayload_AppliesTransform()
public void ApplyPayload_AppliesLocalValuesToTransform() public void ApplyPayload_AppliesLocalValuesToTransform()
{ {
const uint netId = 1000; const uint netId = 1000;
GameObject parent = new GameObject(); CreateGameObject(out GameObject parent);
_createdObjects.Add(parent);
parent.transform.position = new Vector3(100, 20, 0); parent.transform.position = new Vector3(100, 20, 0);
parent.transform.rotation = Quaternion.LookRotation(Vector3.left); parent.transform.rotation = Quaternion.LookRotation(Vector3.left);
parent.transform.localScale = Vector3.one * 2; parent.transform.localScale = Vector3.one * 2;
GameObject go = new GameObject(); CreateNetworked(out GameObject go, out NetworkIdentity identity);
go.transform.parent = parent.transform; go.transform.parent = parent.transform;
NetworkIdentity identity = go.AddComponent<NetworkIdentity>();
Vector3 position = new Vector3(10, 0, 20); Vector3 position = new Vector3(10, 0, 20);
Quaternion rotation = Quaternion.Euler(0, 45, 0); Quaternion rotation = Quaternion.Euler(0, 45, 0);
@ -412,10 +409,7 @@ public void ApplyPayload_AppliesAuthority(bool isOwner)
{ {
const uint netId = 1000; const uint netId = 1000;
GameObject go = new GameObject(); CreateNetworked(out GameObject go, out NetworkIdentity identity);
_createdObjects.Add(go);
NetworkIdentity identity = go.AddComponent<NetworkIdentity>();
SpawnMessage msg = new SpawnMessage SpawnMessage msg = new SpawnMessage
{ {
@ -429,7 +423,7 @@ public void ApplyPayload_AppliesAuthority(bool isOwner)
rotation = Quaternion.identity, rotation = Quaternion.identity,
scale = Vector3.one, scale = Vector3.one,
payload = default, payload = default
}; };
// set to opposite to make sure it is changed // set to opposite to make sure it is changed