@@ -322,7 +322,7 @@ public void SetDefaultDespawnType(DespawnType despawnType)
322
322
/// <summary>
323
323
/// Becomes true once initialized values are set.
324
324
/// </summary>
325
- [ System . NonSerialized ]
325
+ [ SerializeField , HideInInspector ]
326
326
private bool _initializedValusSet ;
327
327
#endregion
328
328
@@ -363,7 +363,7 @@ protected virtual void Awake()
363
363
/* If networkBehaviours are not yet initialized then do so now.
364
364
* After initializing at least 1 networkBehaviour will always exist
365
365
* as emptyNetworkBehaviour is added automatically when none are present. */
366
- if ( NetworkBehaviours == null || NetworkBehaviours . Count == 0 )
366
+ if ( ! _initializedValusSet )
367
367
{
368
368
bool isNested = false ;
369
369
//Make sure there are no networkObjects above this since initializing will trickle down.
@@ -381,7 +381,7 @@ protected virtual void Awake()
381
381
382
382
//If not nested then init
383
383
if ( ! isNested )
384
- SetInitializedValues ( parentNob : null ) ;
384
+ SetInitializedValues ( parentNob : null , force : false ) ;
385
385
}
386
386
387
387
SetChildDespawnedState ( ) ;
@@ -852,17 +852,17 @@ private bool IsInvalidParent(NetworkBehaviour nb)
852
852
/// Sets values as they are during initialization, such as componentId, NetworkBehaviour Ids, and more.
853
853
/// Starts with a 0 componentId.
854
854
/// </summary>
855
- internal void SetInitializedValues ( NetworkObject parentNob )
855
+ internal void SetInitializedValues ( NetworkObject parentNob , bool force = false )
856
856
{
857
857
byte componentId = 0 ;
858
- SetInitializedValues ( parentNob , ref componentId ) ;
858
+ SetInitializedValues ( parentNob , ref componentId , force ) ;
859
859
}
860
860
861
861
/// <summary>
862
862
/// Sets values as they are during initialization, such as componentId, NetworkBehaviour Ids, and more.
863
863
/// </summary>
864
864
/// <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 )
866
866
{
867
867
if ( ! ApplicationState . IsPlaying ( ) )
868
868
{
@@ -872,7 +872,7 @@ internal void SetInitializedValues(NetworkObject parentNob, ref byte componentId
872
872
873
873
/* If NetworkBehaviours is null then all collections are.
874
874
* Set values for each collection. */
875
- if ( ! _initializedValusSet )
875
+ if ( force || ! _initializedValusSet )
876
876
{
877
877
/* This only runs when playing, so it's safe to return existing to the pool. */
878
878
StoreCollections ( ) ;
@@ -1009,7 +1009,7 @@ internal void SetInitializedValues(NetworkObject parentNob, ref byte componentId
1009
1009
foreach ( NetworkObject item in InitializedNestedNetworkObjects )
1010
1010
{
1011
1011
componentId ++ ;
1012
- item . SetInitializedValues ( this , ref componentId ) ;
1012
+ item . SetInitializedValues ( this , ref componentId , force ) ;
1013
1013
}
1014
1014
1015
1015
//Update global states to that of this one.
0 commit comments