Skip to content

Commit 484a2b0

Browse files
committed
Init command-line options singleton when used
1 parent 9295143 commit 484a2b0

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

com.unity.netcode.gameobjects/Runtime/Configuration/CommandLineOptions.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,32 @@ namespace Unity.Netcode
1111
public class CommandLineOptions
1212
{
1313
/// <summary>
14-
/// Command Line Options Singleton
14+
/// Command-line options singleton
1515
/// </summary>
16-
public static CommandLineOptions Instance { get; private set; } = null!;
16+
public static CommandLineOptions Instance
17+
{
18+
get
19+
{
20+
if (s_Instance == null)
21+
{
22+
s_Instance = new CommandLineOptions();
23+
}
24+
return s_Instance;
25+
}
26+
private set
27+
{
28+
s_Instance = value;
29+
}
30+
}
31+
private static CommandLineOptions s_Instance;
1732

1833
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
1934
private static void RuntimeInitializeOnLoad() => Instance = new CommandLineOptions();
2035

2136
// Contains the current application instance domain's command line arguments
2237
internal static List<string> CommandLineArguments = new List<string>();
2338

24-
// Invoked upon application start
39+
// Invoked upon application start, after scene load
2540
[RuntimeInitializeOnLoadMethod]
2641
private static void ParseCommandLineArguments()
2742
{

0 commit comments

Comments
 (0)