File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
MLAPI/MonoBehaviours/Core Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,11 @@ private void OnEnable()
109109 if ( _networkedObject == null )
110110 _networkedObject = GetComponentInParent < NetworkedObject > ( ) ;
111111
112- CacheAttributedMethods ( ) ;
112+ if ( NetworkingManager . singleton != null )
113+ CacheAttributedMethods ( ) ;
114+ else
115+ NetworkingManager . onSingletonSet += CacheAttributedMethods ;
116+
113117 NetworkedObject . NetworkedBehaviours . Add ( this ) ;
114118 }
115119
@@ -187,7 +191,7 @@ public virtual void OnSetLocalVisibility(bool visible)
187191
188192 private void CacheAttributedMethods ( )
189193 {
190- if ( NetworkingManager . singleton . NetworkConfig != null && NetworkingManager . singleton . NetworkConfig . AttributeMessageMode == AttributeMessageMode . Disabled )
194+ if ( NetworkingManager . singleton . NetworkConfig . AttributeMessageMode == AttributeMessageMode . Disabled )
191195 return ;
192196
193197 MethodInfo [ ] methods = GetType ( ) . GetMethods ( BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance | BindingFlags . FlattenHierarchy ) ;
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ public bool IsClientConnected
164164 /// An inspector bool that acts as a Trigger for regenerating RSA keys. Should not be used outside Unity editor.
165165 /// </summary>
166166 public bool RegenerateRSAKeys = false ;
167+ internal static Action onSingletonSet ;
167168
168169 private void OnValidate ( )
169170 {
@@ -643,6 +644,8 @@ private void OnEnable()
643644 DontDestroyOnLoad ( gameObject ) ;
644645 if ( RunInBackground )
645646 Application . runInBackground = true ;
647+
648+ onSingletonSet ( ) ;
646649 }
647650
648651 private void OnDestroy ( )
You can’t perform that action at this time.
0 commit comments