Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit a6c24f9

Browse files
committed
Add startup delay
1 parent 9e4c335 commit a6c24f9

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/Core/Config/ConfigManager.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public static class ConfigManager
2424
public static ConfigElement<string> Default_Output_Path;
2525
public static ConfigElement<bool> Log_Unity_Debug;
2626
public static ConfigElement<bool> Hide_On_Startup;
27+
public static ConfigElement<float> Startup_Delay_Time;
2728

2829
public static ConfigElement<string> Last_Window_Anchors;
2930
public static ConfigElement<string> Last_Window_Position;
@@ -85,6 +86,10 @@ private static void CreateConfigElements()
8586
"The default output path when exporting things from UnityExplorer.",
8687
Path.Combine(ExplorerCore.Loader.ExplorerFolder, "Output"));
8788

89+
Startup_Delay_Time = new ConfigElement<float>("Startup Delay Time",
90+
"The delay on startup before the UI is created.",
91+
1f);
92+
8893
// Internal configs
8994

9095
Last_Window_Anchors = new ConfigElement<string>("Last_Window_Anchors",

src/ExplorerCore.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections;
23
using System.IO;
34
using UnityEngine;
45
using UnityExplorer.Core.Config;
@@ -13,7 +14,7 @@ namespace UnityExplorer
1314
public class ExplorerCore
1415
{
1516
public const string NAME = "UnityExplorer";
16-
public const string VERSION = "3.3.11";
17+
public const string VERSION = "3.3.12";
1718
public const string AUTHOR = "Sinai";
1819
public const string GUID = "com.sinai.unityexplorer";
1920

@@ -44,10 +45,24 @@ public static void Init(IExplorerLoader loader)
4445

4546
InputManager.Init();
4647

47-
UIManager.Init();
48-
4948
Log($"{NAME} {VERSION} initialized.");
5049

50+
RuntimeProvider.Instance.StartCoroutine(SetupCoroutine());
51+
}
52+
53+
// Do a delayed setup so that objects aren't destroyed instantly.
54+
// This can happen for a multitude of reasons.
55+
// Default delay is 1 second which is usually enough.
56+
private static IEnumerator SetupCoroutine()
57+
{
58+
float f = Time.realtimeSinceStartup;
59+
float delay = ConfigManager.Startup_Delay_Time.Value;
60+
while (Time.realtimeSinceStartup - f < delay)
61+
yield return null;
62+
63+
Log($"Creating UI, after delay of {delay} second(s).");
64+
UIManager.Init();
65+
5166
//InspectorManager.Instance.Inspect(typeof(TestClass));
5267
}
5368

0 commit comments

Comments
 (0)