mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
NetworkIdentityTests: GetSyncVarGameObjectOnClient
This commit is contained in:
parent
8acdd76699
commit
01a16581b3
@ -1099,6 +1099,43 @@ public void GetSyncVarGameObjectOnServerNull()
|
||||
NetworkServer.Shutdown();
|
||||
Transport.activeTransport = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSyncVarGameObjectOnClient()
|
||||
{
|
||||
// are we on client and not on server?
|
||||
identity.isClient = true;
|
||||
Assert.That(identity.isServer, Is.False);
|
||||
|
||||
// add test component
|
||||
NetworkBehaviourGetSyncVarGameObjectComponent comp = gameObject.AddComponent<NetworkBehaviourGetSyncVarGameObjectComponent>();
|
||||
comp.syncInterval = 0; // for isDirty check
|
||||
|
||||
// create a syncable GameObject
|
||||
GameObject go = new GameObject();
|
||||
NetworkIdentity ni = go.AddComponent<NetworkIdentity>();
|
||||
ni.netId = 43;
|
||||
|
||||
// register in spawned dict because clients should look it up via
|
||||
// netId
|
||||
NetworkIdentity.spawned[ni.netId] = ni;
|
||||
|
||||
// assign ONLY netId in the component. assume that GameObject was
|
||||
// assigned earlier but client walked so far out of range that it
|
||||
// was despawned on the client. so it's forced to do the netId look-
|
||||
// up.
|
||||
Assert.That(comp.test, Is.Null);
|
||||
comp.testNetId = ni.netId;
|
||||
|
||||
// get it on the client. should look up netId in spawned
|
||||
GameObject result = comp.GetSyncVarGameObjectExposed();
|
||||
Assert.That(result, Is.EqualTo(go));
|
||||
|
||||
// clean up
|
||||
NetworkServer.Shutdown();
|
||||
Transport.activeTransport = null;
|
||||
GameObject.DestroyImmediate(go);
|
||||
}
|
||||
}
|
||||
|
||||
// we need to inherit from networkbehaviour to test protected functions
|
||||
|
Loading…
Reference in New Issue
Block a user