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()
109
109
if ( _networkedObject == null )
110
110
_networkedObject = GetComponentInParent < NetworkedObject > ( ) ;
111
111
112
- CacheAttributedMethods ( ) ;
112
+ if ( NetworkingManager . singleton != null )
113
+ CacheAttributedMethods ( ) ;
114
+ else
115
+ NetworkingManager . onSingletonSet += CacheAttributedMethods ;
116
+
113
117
NetworkedObject . NetworkedBehaviours . Add ( this ) ;
114
118
}
115
119
@@ -187,7 +191,7 @@ public virtual void OnSetLocalVisibility(bool visible)
187
191
188
192
private void CacheAttributedMethods ( )
189
193
{
190
- if ( NetworkingManager . singleton . NetworkConfig != null && NetworkingManager . singleton . NetworkConfig . AttributeMessageMode == AttributeMessageMode . Disabled )
194
+ if ( NetworkingManager . singleton . NetworkConfig . AttributeMessageMode == AttributeMessageMode . Disabled )
191
195
return ;
192
196
193
197
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
164
164
/// An inspector bool that acts as a Trigger for regenerating RSA keys. Should not be used outside Unity editor.
165
165
/// </summary>
166
166
public bool RegenerateRSAKeys = false ;
167
+ internal static Action onSingletonSet ;
167
168
168
169
private void OnValidate ( )
169
170
{
@@ -643,6 +644,8 @@ private void OnEnable()
643
644
DontDestroyOnLoad ( gameObject ) ;
644
645
if ( RunInBackground )
645
646
Application . runInBackground = true ;
647
+
648
+ onSingletonSet ( ) ;
646
649
}
647
650
648
651
private void OnDestroy ( )
You can’t perform that action at this time.
0 commit comments