Skip to content

Commit 128427f

Browse files
committed
removing uses of the null-coalescing operator
1 parent 20b94c6 commit 128427f

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

Assets/Scripts/UnityServices/Lobbies/LobbyServiceFacade.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,11 @@ public async Task UpdateLobbyDataAsync(Dictionary<string, DataObject> data)
473473
return;
474474
}
475475

476-
var dataCurr = CurrentUnityLobby.Data ?? new Dictionary<string, DataObject>();
476+
var dataCurr = CurrentUnityLobby.Data;
477+
if (dataCurr == null)
478+
{
479+
dataCurr = new Dictionary<string, DataObject>();
480+
}
477481

478482
foreach (var dataNew in data)
479483
{

Assets/Scripts/Utils/ProfileManager.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ public string Profile
2121
{
2222
get
2323
{
24-
return m_Profile ??= GetProfile();
24+
if (m_Profile == null)
25+
{
26+
m_Profile = GetProfile();
27+
}
28+
29+
return m_Profile;
2530
}
2631
set
2732
{

Packages/com.unity.multiplayer.samples.coop/Utilities/EditorChildSceneLoader.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ void Update()
2323

2424
public void SaveSceneSetup()
2525
{
26-
ChildScenesToLoadConfig ??= new List<SceneAsset>();
27-
ChildScenesToLoadConfig.Clear();
26+
if (ChildScenesToLoadConfig == null)
27+
{
28+
ChildScenesToLoadConfig = new List<SceneAsset>();
29+
}
30+
else
31+
{
32+
ChildScenesToLoadConfig.Clear();
33+
}
2834
foreach (var sceneSetup in EditorSceneManager.GetSceneManagerSetup())
2935
{
3036
ChildScenesToLoadConfig.Add(AssetDatabase.LoadAssetAtPath<SceneAsset>(sceneSetup.path));

Packages/com.unity.multiplayer.samples.coop/Utilities/Net/SessionManager.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,18 @@ public class SessionManager<T> where T : struct, ISessionPlayerData
3030
m_ClientIDToPlayerId = new Dictionary<ulong, string>();
3131
}
3232

33-
public static SessionManager<T> Instance => s_Instance ??= new SessionManager<T>();
33+
public static SessionManager<T> Instance
34+
{
35+
get
36+
{
37+
if (s_Instance == null)
38+
{
39+
s_Instance = new SessionManager<T>();
40+
}
41+
42+
return s_Instance;
43+
}
44+
}
3445

3546
static SessionManager<T> s_Instance;
3647

0 commit comments

Comments
 (0)