@@ -322,7 +322,7 @@ public void SetDefaultDespawnType(DespawnType despawnType)
322322 /// <summary>
323323 /// Becomes true once initialized values are set.
324324 /// </summary>
325- [ System . NonSerialized ]
325+ [ SerializeField , HideInInspector ]
326326 private bool _initializedValusSet ;
327327 #endregion
328328
@@ -363,7 +363,7 @@ protected virtual void Awake()
363363 /* If networkBehaviours are not yet initialized then do so now.
364364 * After initializing at least 1 networkBehaviour will always exist
365365 * as emptyNetworkBehaviour is added automatically when none are present. */
366- if ( NetworkBehaviours == null || NetworkBehaviours . Count == 0 )
366+ if ( ! _initializedValusSet )
367367 {
368368 bool isNested = false ;
369369 //Make sure there are no networkObjects above this since initializing will trickle down.
@@ -381,7 +381,7 @@ protected virtual void Awake()
381381
382382 //If not nested then init
383383 if ( ! isNested )
384- SetInitializedValues ( parentNob : null ) ;
384+ SetInitializedValues ( parentNob : null , force : false ) ;
385385 }
386386
387387 SetChildDespawnedState ( ) ;
@@ -852,17 +852,17 @@ private bool IsInvalidParent(NetworkBehaviour nb)
852852 /// Sets values as they are during initialization, such as componentId, NetworkBehaviour Ids, and more.
853853 /// Starts with a 0 componentId.
854854 /// </summary>
855- internal void SetInitializedValues ( NetworkObject parentNob )
855+ internal void SetInitializedValues ( NetworkObject parentNob , bool force = false )
856856 {
857857 byte componentId = 0 ;
858- SetInitializedValues ( parentNob , ref componentId ) ;
858+ SetInitializedValues ( parentNob , ref componentId , force ) ;
859859 }
860860
861861 /// <summary>
862862 /// Sets values as they are during initialization, such as componentId, NetworkBehaviour Ids, and more.
863863 /// </summary>
864864 /// <param name="componentId">ComponentId to start from for the NetworkObject.</param>
865- internal void SetInitializedValues ( NetworkObject parentNob , ref byte componentId )
865+ internal void SetInitializedValues ( NetworkObject parentNob , ref byte componentId , bool force = false )
866866 {
867867 if ( ! ApplicationState . IsPlaying ( ) )
868868 {
@@ -872,7 +872,7 @@ internal void SetInitializedValues(NetworkObject parentNob, ref byte componentId
872872
873873 /* If NetworkBehaviours is null then all collections are.
874874 * Set values for each collection. */
875- if ( ! _initializedValusSet )
875+ if ( force || ! _initializedValusSet )
876876 {
877877 /* This only runs when playing, so it's safe to return existing to the pool. */
878878 StoreCollections ( ) ;
@@ -1009,7 +1009,7 @@ internal void SetInitializedValues(NetworkObject parentNob, ref byte componentId
10091009 foreach ( NetworkObject item in InitializedNestedNetworkObjects )
10101010 {
10111011 componentId ++ ;
1012- item . SetInitializedValues ( this , ref componentId ) ;
1012+ item . SetInitializedValues ( this , ref componentId , force ) ;
10131013 }
10141014
10151015 //Update global states to that of this one.
0 commit comments