Skip to content

Commit ac31f46

Browse files
committed
Fixed nullRef on first OnValidate call
1 parent 11c6890 commit ac31f46

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

MLAPI/MLAPI.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
</PropertyGroup>
3737
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Development|AnyCPU'">
3838
<DebugSymbols>true</DebugSymbols>
39-
<OutputPath>..\..\MLAPI-Examples\Assets\</OutputPath>
39+
<OutputPath>..\..\MLAPI-Examples\Assets\MLAPI\</OutputPath>
4040
<DefineConstants>DEBUG;TRACE</DefineConstants>
4141
<DebugType>full</DebugType>
4242
<PlatformTarget>AnyCPU</PlatformTarget>
4343
<ErrorReport>prompt</ErrorReport>
4444
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
45-
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
45+
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
4646
<RunCodeAnalysis>false</RunCodeAnalysis>
4747
<DocumentationFile>
4848
</DocumentationFile>

MLAPI/MonoBehaviours/Core/NetworkingManager.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,20 @@ public bool IsClientConnected
153153

154154
private void OnValidate()
155155
{
156+
if (NetworkConfig == null)
157+
return; //May occur when the component is added
158+
156159
if(NetworkConfig.EnableSceneSwitching && !NetworkConfig.RegisteredScenes.Contains(SceneManager.GetActiveScene().name))
157160
{
158161
Debug.LogWarning("MLAPI: The active scene is not registered as a networked scene. The MLAPI has added it");
159162
NetworkConfig.RegisteredScenes.Add(SceneManager.GetActiveScene().name);
160163
}
164+
161165
if(!NetworkConfig.EnableSceneSwitching && NetworkConfig.HandleObjectSpawning)
162166
{
163167
Debug.LogWarning("MLAPI: Please be aware that Scene objects are NOT supported if SceneManagement is turned on, even if HandleObjectSpawning is turned on");
164168
}
169+
165170
if(NetworkConfig.HandleObjectSpawning)
166171
{
167172
for (int i = 0; i < NetworkConfig.NetworkedPrefabs.Count; i++)
@@ -173,6 +178,7 @@ private void OnValidate()
173178
}
174179
}
175180
}
181+
176182
if (NetworkConfig.HandleObjectSpawning)
177183
{
178184
if(!string.IsNullOrEmpty(NetworkConfig.PlayerPrefabName))
@@ -198,7 +204,9 @@ private void OnValidate()
198204
}
199205

200206
if (!NetworkConfig.EnableEncryption)
207+
{
201208
RegenerateRSAKeys = false;
209+
}
202210
else
203211
{
204212
if(RegenerateRSAKeys)

0 commit comments

Comments
 (0)