@@ -48,6 +48,26 @@ public class StructHavingNetworkBehaviour : TemplateNetworkBehaviourType<TestStr
4848
4949 }
5050
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+
5171 [ TestFixtureSource ( nameof ( TestDataSource ) ) ]
5272 public class NetworkVariablePermissionTests : NetcodeIntegrationTest
5373 {
@@ -433,6 +453,7 @@ public enum SomeEnum
433453 public readonly NetworkVariable < int > TheScalar = new NetworkVariable < int > ( ) ;
434454 public readonly NetworkVariable < SomeEnum > TheEnum = new NetworkVariable < SomeEnum > ( ) ;
435455 public readonly NetworkList < int > TheList = new NetworkList < int > ( ) ;
456+ public readonly NetworkList < StructUsedOnlyInNetworkList > TheStructList = new NetworkList < StructUsedOnlyInNetworkList > ( ) ;
436457 public readonly NetworkList < FixedString128Bytes > TheLargeList = new NetworkList < FixedString128Bytes > ( ) ;
437458
438459 public readonly NetworkVariable < FixedString32Bytes > FixedString32 = new NetworkVariable < FixedString32Bytes > ( ) ;
@@ -449,7 +470,6 @@ public void Awake()
449470
450471 public readonly NetworkVariable < TestStruct > TheStruct = new NetworkVariable < TestStruct > ( ) ;
451472 public readonly NetworkVariable < TestClass > TheClass = new NetworkVariable < TestClass > ( ) ;
452- public readonly NetworkList < TestStruct > TheListOfStructs = new NetworkList < TestStruct > ( ) ;
453473
454474 public NetworkVariable < UnmanagedTemplateNetworkSerializableType < TestStruct > > TheTemplateStruct = new NetworkVariable < UnmanagedTemplateNetworkSerializableType < TestStruct > > ( ) ;
455475 public NetworkVariable < ManagedTemplateNetworkSerializableType < TestClass > > TheTemplateClass = new NetworkVariable < ManagedTemplateNetworkSerializableType < TestClass > > ( ) ;
@@ -813,6 +833,26 @@ bool VerifyClass()
813833 yield return WaitForConditionOrTimeOut ( VerifyClass ) ;
814834 }
815835
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+
816856 [ UnityTest ]
817857 public IEnumerator TestNetworkVariableStruct ( [ Values ( true , false ) ] bool useHost )
818858 {
0 commit comments