diff --git a/com.unity.netcode.gameobjects/CHANGELOG.md b/com.unity.netcode.gameobjects/CHANGELOG.md
index 1725dd9c44..ca084c439e 100644
--- a/com.unity.netcode.gameobjects/CHANGELOG.md
+++ b/com.unity.netcode.gameobjects/CHANGELOG.md
@@ -19,9 +19,9 @@ Additional documentation and release notes are available at [Multiplayer Documen
- Renamed the NetworkTransform.SetState parameter `shouldGhostsInterpolate` to `teleportDisabled` for better clarity of what that parameter does. (#2228)
### Fixed
+- Fixed issue where `NetcodeSettingsProvider` would throw an exception in Unity 2020.3.x versions. (#2345)
- Fixed server side issue where, depending upon component ordering, some NetworkBehaviour components might not have their OnNetworkDespawn method invoked if the client side disconnected. (#2323)
- Fixed a case where data corruption could occur when using UnityTransport when reaching a certain level of send throughput. (#2332)
-
- Fixed an issue in `UnityTransport` where an exception would be thrown if starting a Relay host/server on WebGL. This exception should only be thrown if using direct connections (where WebGL can't act as a host/server). (#2321)
## [1.2.0] - 2022-11-21
diff --git a/com.unity.netcode.gameobjects/Editor/Configuration/NetcodeSettingsProvider.cs b/com.unity.netcode.gameobjects/Editor/Configuration/NetcodeSettingsProvider.cs
index c0f27adb52..5e92222874 100644
--- a/com.unity.netcode.gameobjects/Editor/Configuration/NetcodeSettingsProvider.cs
+++ b/com.unity.netcode.gameobjects/Editor/Configuration/NetcodeSettingsProvider.cs
@@ -20,14 +20,46 @@ public static SettingsProvider CreateNetcodeSettingsProvider()
return provider;
}
- internal static NetcodeSettingsLabel NetworkObjectsSectionLabel = new NetcodeSettingsLabel("NetworkObject Helper Settings", 20);
- internal static NetcodeSettingsToggle AutoAddNetworkObjectToggle = new NetcodeSettingsToggle("Auto-Add NetworkObjects", "When enabled, NetworkObjects are automatically added to GameObjects when NetworkBehaviours are added first.", 20);
- internal static NetcodeSettingsLabel MultiplayerToolsLabel = new NetcodeSettingsLabel("Multiplayer Tools", 20);
- internal static NetcodeSettingsToggle MultiplayerToolTipStatusToggle = new NetcodeSettingsToggle("Multiplayer Tools Install Reminder", "When enabled, the NetworkManager will display " +
- "the notification to install the multiplayer tools package.", 20);
+ internal static NetcodeSettingsLabel NetworkObjectsSectionLabel;
+ internal static NetcodeSettingsToggle AutoAddNetworkObjectToggle;
+ internal static NetcodeSettingsLabel MultiplayerToolsLabel;
+ internal static NetcodeSettingsToggle MultiplayerToolTipStatusToggle;
+
+ ///
+ /// Creates an instance of the settings UI Elements if they don't already exist.
+ ///
+ ///
+ /// We have to construct any NetcodeGUISettings derived classes here because in
+ /// version 2020.x.x EditorStyles.label does not exist yet (higher versions it does)
+ ///
+ private static void CheckForInitialize()
+ {
+ if (NetworkObjectsSectionLabel == null)
+ {
+ NetworkObjectsSectionLabel = new NetcodeSettingsLabel("NetworkObject Helper Settings", 20);
+ }
+
+ if (AutoAddNetworkObjectToggle == null)
+ {
+ AutoAddNetworkObjectToggle = new NetcodeSettingsToggle("Auto-Add NetworkObjects", "When enabled, NetworkObjects are automatically added to GameObjects when NetworkBehaviours are added first.", 20);
+ }
+
+ if (MultiplayerToolsLabel == null)
+ {
+ MultiplayerToolsLabel = new NetcodeSettingsLabel("Multiplayer Tools", 20);
+ }
+
+ if (MultiplayerToolTipStatusToggle == null)
+ {
+ MultiplayerToolTipStatusToggle = new NetcodeSettingsToggle("Multiplayer Tools Install Reminder", "When enabled, the NetworkManager will display the notification to install the multiplayer tools package.", 20);
+ }
+ }
private static void OnGuiHandler(string obj)
{
+ // Make sure all NetcodeGUISettings derived classes are instantiated first
+ CheckForInitialize();
+
var autoAddNetworkObjectSetting = NetcodeForGameObjectsSettings.GetAutoAddNetworkObjectSetting();
var multiplayerToolsTipStatus = NetcodeForGameObjectsSettings.GetNetcodeInstallMultiplayerToolTips() == 0;
EditorGUI.BeginChangeCheck();
@@ -56,7 +88,7 @@ public void DrawLabel()
public NetcodeSettingsLabel(string labelText, float layoutOffset = 0.0f)
{
m_LabelContent = labelText;
- AdjustLableSize(labelText, layoutOffset);
+ AdjustLabelSize(labelText, layoutOffset);
}
}
@@ -72,7 +104,7 @@ public bool DrawToggle(bool currentSetting)
public NetcodeSettingsToggle(string labelText, string toolTip, float layoutOffset)
{
- AdjustLableSize(labelText, layoutOffset);
+ AdjustLabelSize(labelText, layoutOffset);
m_ToggleContent = new GUIContent(labelText, toolTip);
}
}
@@ -84,11 +116,10 @@ internal class NetcodeGUISettings
protected GUILayoutOption m_LayoutWidth { get; private set; }
- protected void AdjustLableSize(string labelText, float offset = 0.0f)
+ protected void AdjustLabelSize(string labelText, float offset = 0.0f)
{
m_LabelSize = Mathf.Min(k_MaxLabelWidth, EditorStyles.label.CalcSize(new GUIContent(labelText)).x);
m_LayoutWidth = GUILayout.Width(m_LabelSize + offset);
}
}
-
}