Skip to content

Commit d29232a

Browse files
committed
small test fixes
1 parent 6f2f944 commit d29232a

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NetworkTransformOwnershipTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ protected override void OnCreatePlayerPrefab()
656656
private void RandomizeObjectTransformPositions(GameObject gameObject)
657657
{
658658
var networkObject = gameObject.GetComponent<NetworkObject>();
659+
networkObject.InitializeChildNetworkBehaviours();
659660
Assert.True(networkObject.ChildNetworkBehaviours.Count > 0);
660661

661662
foreach (var networkTransform in networkObject.NetworkTransforms)

com.unity.netcode.gameobjects/Tests/Runtime/TestHelpers/NetcodeIntegrationTest.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2650,16 +2650,12 @@ public static void SimulateOneFrame()
26502650
{
26512651
var method = obj.GetType().GetMethod(methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
26522652
method?.Invoke(obj, new object[] { });
2653-
if (obj.ChildNetworkBehaviours == null)
2654-
{
2655-
obj.InitializeChildNetworkBehaviours();
2656-
}
2657-
2658-
foreach (var behaviour in obj.ChildNetworkBehaviours)
2659-
{
2660-
var behaviourMethod = behaviour.GetType().GetMethod(methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
2661-
behaviourMethod?.Invoke(behaviour, new object[] { });
2662-
}
2653+
}
2654+
var networkBehaviours = FindObjects.ByType<NetworkBehaviour>();
2655+
foreach (var behaviour in networkBehaviours)
2656+
{
2657+
var behaviourMethod = behaviour.GetType().GetMethod(methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
2658+
behaviourMethod?.Invoke(behaviour, new object[] { });
26632659
}
26642660
}
26652661
}

0 commit comments

Comments
 (0)