mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix: NetworkBehaviour.SyncVarNetworkIdentityEqual made protected again so that Weaver finds it again
This commit is contained in:
parent
165a1dd94c
commit
20a2d09d07
@ -537,8 +537,10 @@ protected GameObject GetSyncVarGameObject(uint netId, ref GameObject gameObjectF
|
||||
}
|
||||
|
||||
// helper function for [SyncVar] NetworkIdentities.
|
||||
// IMPORTANT: keep as 'protected', not 'internal', otherwise Weaver
|
||||
// can't resolve it
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
internal bool SyncVarNetworkIdentityEqual(NetworkIdentity newIdentity, uint netIdField)
|
||||
protected bool SyncVarNetworkIdentityEqual(NetworkIdentity newIdentity, uint netIdField)
|
||||
{
|
||||
uint newNetId = 0;
|
||||
if (newIdentity != null)
|
||||
|
@ -21,6 +21,14 @@ public bool SyncVarGameObjectEqualExposed(GameObject newGameObject, uint netIdFi
|
||||
}
|
||||
}
|
||||
|
||||
class SyncVarNetworkIdentityEqualExposedBehaviour : NetworkBehaviour
|
||||
{
|
||||
public bool SyncVarNetworkIdentityEqualExposed(NetworkIdentity newNetworkIdentity, uint netIdField)
|
||||
{
|
||||
return SyncVarNetworkIdentityEqual(newNetworkIdentity, netIdField);
|
||||
}
|
||||
}
|
||||
|
||||
// we need to inherit from networkbehaviour to test protected functions
|
||||
public class NetworkBehaviourSendCommandInternalComponent : NetworkBehaviour
|
||||
{
|
||||
@ -923,7 +931,8 @@ public void SyncVarNetworkIdentityEqualZeroNetIdNullIsTrue()
|
||||
// better to return false here.
|
||||
// => we possibly return false so that resync doesn't happen when
|
||||
// GO disappears? or not?
|
||||
bool result = emptyBehaviour.SyncVarNetworkIdentityEqual(null, identity.netId);
|
||||
SyncVarNetworkIdentityEqualExposedBehaviour comp = gameObject.AddComponent<SyncVarNetworkIdentityEqualExposedBehaviour>();
|
||||
bool result = comp.SyncVarNetworkIdentityEqualExposed(null, identity.netId);
|
||||
Assert.That(result, Is.True);
|
||||
}
|
||||
|
||||
@ -935,7 +944,8 @@ public void SyncVarNetworkIdentityEqualNull()
|
||||
identity.netId = 42;
|
||||
|
||||
// null should return false
|
||||
bool result = emptyBehaviour.SyncVarNetworkIdentityEqual(null, identity.netId);
|
||||
SyncVarNetworkIdentityEqualExposedBehaviour comp = gameObject.AddComponent<SyncVarNetworkIdentityEqualExposedBehaviour>();
|
||||
bool result = comp.SyncVarNetworkIdentityEqualExposed(null, identity.netId);
|
||||
Assert.That(result, Is.False);
|
||||
}
|
||||
|
||||
@ -949,8 +959,9 @@ public void SyncVarNetworkIdentityEqualValidIdentityWithDifferentNetId()
|
||||
// gameobject with valid networkidentity and netid that is different
|
||||
GameObject go = new GameObject();
|
||||
NetworkIdentity ni = go.AddComponent<NetworkIdentity>();
|
||||
SyncVarNetworkIdentityEqualExposedBehaviour comp = go.AddComponent<SyncVarNetworkIdentityEqualExposedBehaviour>();
|
||||
ni.netId = 43;
|
||||
bool result = emptyBehaviour.SyncVarNetworkIdentityEqual(ni, identity.netId);
|
||||
bool result = comp.SyncVarNetworkIdentityEqualExposed(ni, identity.netId);
|
||||
Assert.That(result, Is.False);
|
||||
|
||||
// clean up
|
||||
@ -967,8 +978,9 @@ public void SyncVarNetworkIdentityEqualValidIdentityWithSameNetId()
|
||||
// gameobject with valid networkidentity and netid that is different
|
||||
GameObject go = new GameObject();
|
||||
NetworkIdentity ni = go.AddComponent<NetworkIdentity>();
|
||||
SyncVarNetworkIdentityEqualExposedBehaviour comp = go.AddComponent<SyncVarNetworkIdentityEqualExposedBehaviour>();
|
||||
ni.netId = 42;
|
||||
bool result = emptyBehaviour.SyncVarNetworkIdentityEqual(ni, identity.netId);
|
||||
bool result = comp.SyncVarNetworkIdentityEqualExposed(ni, identity.netId);
|
||||
Assert.That(result, Is.True);
|
||||
|
||||
// clean up
|
||||
@ -985,8 +997,9 @@ public void SyncVarNetworkIdentityEqualUnspawnedIdentity()
|
||||
// gameobject with valid networkidentity and 0 netid that is unspawned
|
||||
GameObject go = new GameObject();
|
||||
NetworkIdentity ni = go.AddComponent<NetworkIdentity>();
|
||||
SyncVarNetworkIdentityEqualExposedBehaviour comp = go.AddComponent<SyncVarNetworkIdentityEqualExposedBehaviour>();
|
||||
LogAssert.Expect(LogType.Warning, "SetSyncVarNetworkIdentity NetworkIdentity " + ni + " has a zero netId. Maybe it is not spawned yet?");
|
||||
bool result = emptyBehaviour.SyncVarNetworkIdentityEqual(ni, identity.netId);
|
||||
bool result = comp.SyncVarNetworkIdentityEqualExposed(ni, identity.netId);
|
||||
Assert.That(result, Is.False);
|
||||
|
||||
// clean up
|
||||
@ -1000,8 +1013,9 @@ public void SyncVarNetworkIdentityEqualUnspawnedIdentityZeroNetIdIsTrue()
|
||||
// unspawned go and identity.netid==0 returns true (=equal)
|
||||
GameObject go = new GameObject();
|
||||
NetworkIdentity ni = go.AddComponent<NetworkIdentity>();
|
||||
SyncVarNetworkIdentityEqualExposedBehaviour comp = go.AddComponent<SyncVarNetworkIdentityEqualExposedBehaviour>();
|
||||
LogAssert.Expect(LogType.Warning, "SetSyncVarNetworkIdentity NetworkIdentity " + ni + " has a zero netId. Maybe it is not spawned yet?");
|
||||
bool result = emptyBehaviour.SyncVarNetworkIdentityEqual(ni, identity.netId);
|
||||
bool result = comp.SyncVarNetworkIdentityEqualExposed(ni, identity.netId);
|
||||
Assert.That(result, Is.True);
|
||||
|
||||
// clean up
|
||||
|
Loading…
Reference in New Issue
Block a user