@@ -48,6 +48,26 @@ public class StructHavingNetworkBehaviour : TemplateNetworkBehaviourType<TestStr
48
48
49
49
}
50
50
51
+ public struct StructUsedOnlyInNetworkList : IEquatable < StructUsedOnlyInNetworkList > , INetworkSerializeByMemcpy
52
+ {
53
+ public int Value ;
54
+
55
+ public bool Equals ( StructUsedOnlyInNetworkList other )
56
+ {
57
+ return Value == other . Value ;
58
+ }
59
+
60
+ public override bool Equals ( object obj )
61
+ {
62
+ return obj is StructUsedOnlyInNetworkList other && Equals ( other ) ;
63
+ }
64
+
65
+ public override int GetHashCode ( )
66
+ {
67
+ return Value ;
68
+ }
69
+ }
70
+
51
71
[ TestFixtureSource ( nameof ( TestDataSource ) ) ]
52
72
public class NetworkVariablePermissionTests : NetcodeIntegrationTest
53
73
{
@@ -433,6 +453,7 @@ public enum SomeEnum
433
453
public readonly NetworkVariable < int > TheScalar = new NetworkVariable < int > ( ) ;
434
454
public readonly NetworkVariable < SomeEnum > TheEnum = new NetworkVariable < SomeEnum > ( ) ;
435
455
public readonly NetworkList < int > TheList = new NetworkList < int > ( ) ;
456
+ public readonly NetworkList < StructUsedOnlyInNetworkList > TheStructList = new NetworkList < StructUsedOnlyInNetworkList > ( ) ;
436
457
public readonly NetworkList < FixedString128Bytes > TheLargeList = new NetworkList < FixedString128Bytes > ( ) ;
437
458
438
459
public readonly NetworkVariable < FixedString32Bytes > FixedString32 = new NetworkVariable < FixedString32Bytes > ( ) ;
@@ -449,7 +470,6 @@ public void Awake()
449
470
450
471
public readonly NetworkVariable < TestStruct > TheStruct = new NetworkVariable < TestStruct > ( ) ;
451
472
public readonly NetworkVariable < TestClass > TheClass = new NetworkVariable < TestClass > ( ) ;
452
- public readonly NetworkList < TestStruct > TheListOfStructs = new NetworkList < TestStruct > ( ) ;
453
473
454
474
public NetworkVariable < UnmanagedTemplateNetworkSerializableType < TestStruct > > TheTemplateStruct = new NetworkVariable < UnmanagedTemplateNetworkSerializableType < TestStruct > > ( ) ;
455
475
public NetworkVariable < ManagedTemplateNetworkSerializableType < TestClass > > TheTemplateClass = new NetworkVariable < ManagedTemplateNetworkSerializableType < TestClass > > ( ) ;
@@ -813,6 +833,26 @@ bool VerifyClass()
813
833
yield return WaitForConditionOrTimeOut ( VerifyClass ) ;
814
834
}
815
835
836
+ [ UnityTest ]
837
+ public IEnumerator TestNetworkListStruct ( [ Values ( true , false ) ] bool useHost )
838
+ {
839
+ yield return InitializeServerAndClients ( useHost ) ;
840
+
841
+ bool VerifyList ( )
842
+ {
843
+ return m_Player1OnClient1 . TheStructList . Count == m_Player1OnServer . TheStructList . Count &&
844
+ m_Player1OnClient1 . TheStructList [ 0 ] . Value == m_Player1OnServer . TheStructList [ 0 ] . Value &&
845
+ m_Player1OnClient1 . TheStructList [ 1 ] . Value == m_Player1OnServer . TheStructList [ 1 ] . Value ;
846
+ }
847
+
848
+ m_Player1OnServer . TheStructList . Add ( new StructUsedOnlyInNetworkList { Value = 1 } ) ;
849
+ m_Player1OnServer . TheStructList . Add ( new StructUsedOnlyInNetworkList { Value = 2 } ) ;
850
+ m_Player1OnServer . TheStructList . SetDirty ( true ) ;
851
+
852
+ // Wait for the client-side to notify it is finished initializing and spawning.
853
+ yield return WaitForConditionOrTimeOut ( VerifyList ) ;
854
+ }
855
+
816
856
[ UnityTest ]
817
857
public IEnumerator TestNetworkVariableStruct ( [ Values ( true , false ) ] bool useHost )
818
858
{
0 commit comments