check if background thread is running

This commit is contained in:
in0finite 2022-01-24 15:44:27 +01:00
parent edaee31998
commit 3217beb0e9
2 changed files with 27 additions and 0 deletions

View file

@ -161,6 +161,13 @@ namespace SanAndreasUnity.Editor
if (this.IsExportingFromGameFiles) if (this.IsExportingFromGameFiles)
{ {
LoadingThread.Singleton.EnsureBackgroundThreadStarted();
if (!LoadingThread.Singleton.IsBackgroundThreadRunning())
{
EditorUtility.DisplayDialog("", "Background thread for asset loading is not running. Try restarting Unity.", "Ok");
yield break;
}
if (!Loader.HasLoaded) if (!Loader.HasLoaded)
{ {
EditorUtility.DisplayDialog("", "Game data must be loaded first.", "Ok"); EditorUtility.DisplayDialog("", "Game data must be loaded first.", "Ok");

View file

@ -241,6 +241,26 @@ namespace SanAndreasUnity.Behaviours
} }
} }
public bool IsBackgroundThreadRunning()
{
ThreadHelper.ThrowIfNotOnMainThread();
if (null == _thread)
return false;
if (_thread.ThreadState != System.Threading.ThreadState.Running)
return false;
return true;
}
public void EnsureBackgroundThreadStarted()
{
ThreadHelper.ThrowIfNotOnMainThread();
this.StartThread();
}
static void ThreadFunction (object objectParameter) static void ThreadFunction (object objectParameter)
{ {
ThreadParameters threadParameters = (ThreadParameters) objectParameter; ThreadParameters threadParameters = (ThreadParameters) objectParameter;