mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
NetworkIdentityTests: ClearDirtyComponentsDirtyBits
This commit is contained in:
parent
df430e1bfc
commit
eac93e1a27
@ -1003,5 +1003,33 @@ public void ClearObservers()
|
|||||||
// clean up
|
// clean up
|
||||||
GameObject.DestroyImmediate(gameObject);
|
GameObject.DestroyImmediate(gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ClearDirtyComponentsDirtyBits()
|
||||||
|
{
|
||||||
|
// create a networkidentity and add some components
|
||||||
|
GameObject gameObject = new GameObject();
|
||||||
|
NetworkIdentity identity = gameObject.AddComponent<NetworkIdentity>();
|
||||||
|
OnStartClientTestNetworkBehaviour compA = gameObject.AddComponent<OnStartClientTestNetworkBehaviour>();
|
||||||
|
OnStartClientTestNetworkBehaviour compB = gameObject.AddComponent<OnStartClientTestNetworkBehaviour>();
|
||||||
|
|
||||||
|
// set syncintervals so one is always dirty, one is never dirty
|
||||||
|
compA.syncInterval = 0;
|
||||||
|
compB.syncInterval = Mathf.Infinity;
|
||||||
|
|
||||||
|
// set components dirty bits
|
||||||
|
compA.SetDirtyBit(0x0001);
|
||||||
|
compB.SetDirtyBit(0x1001);
|
||||||
|
Assert.That(compA.IsDirty(), Is.True); // dirty because interval reached and mask != 0
|
||||||
|
Assert.That(compB.IsDirty(), Is.False); // not dirty because syncinterval not reached
|
||||||
|
|
||||||
|
// call identity.ClearDirtyComponentsDirtyBits
|
||||||
|
identity.ClearDirtyComponentsDirtyBits();
|
||||||
|
Assert.That(compA.IsDirty(), Is.False); // should be cleared now
|
||||||
|
Assert.That(compB.IsDirty(), Is.False); // should be untouched
|
||||||
|
|
||||||
|
// clean up
|
||||||
|
GameObject.DestroyImmediate(gameObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user