Skip to content

Commit ece2405

Browse files
committed
Added an isInitializing flag.
1 parent 90b3d21 commit ece2405

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Assets/Package/Runtime/Console/ConsoleManager.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,23 @@ public class ConsoleManager : MonoBehaviour, IConsoleManager
2727
private ConsoleHistory inputHistory;
2828

2929
private bool isInitialized;
30+
private bool isInitializing;
3031

3132
private void EnsureInitialized()
3233
{
33-
if (isInitialized)
34+
if (isInitialized || isInitializing)
3435
{
3536
return;
3637
}
3738

39+
isInitializing = true;
40+
3841
ValidateSettings();
3942
InitializeHistory();
4043
InitializeCommands();
44+
4145
isInitialized = true;
46+
isInitializing = false;
4247
}
4348

4449
private void ValidateSettings()
@@ -172,6 +177,8 @@ private void RegisterMethodFromCommand(ConsoleCommand command, MethodInfo method
172177

173178
public void AppendCommand(ConsoleCommand command)
174179
{
180+
EnsureInitialized();
181+
175182
var commandType = command.GetType();
176183
var commandInfo = commandType.GetTypeInfo();
177184
foreach (var method in commandInfo.DeclaredMethods.Where(method => method.IsPublic))

0 commit comments

Comments
 (0)