start thread also in edit mode

This commit is contained in:
in0finite 2022-01-23 07:04:08 +01:00
parent 86ed0369a7
commit a3cddc0209

View file

@ -75,12 +75,21 @@ namespace SanAndreasUnity.Behaviours
public ushort maxTimePerFrameMs = 0; public ushort maxTimePerFrameMs = 0;
#if UNITY_EDITOR
[UnityEditor.InitializeOnLoadMethod]
static void InitOnLoadInEditor()
{
if (null == Singleton)
return;
Singleton.StartThread();
}
#endif
protected override void OnSingletonStart() protected override void OnSingletonStart()
{ {
this.StartThread();
_thread = new Thread (ThreadFunction);
_thread.Start(_threadParameters);
} }
protected override void OnSingletonDisable() protected override void OnSingletonDisable()
@ -97,6 +106,15 @@ namespace SanAndreasUnity.Behaviours
} }
} }
void StartThread()
{
if (_thread != null)
return;
_thread = new Thread(ThreadFunction);
_thread.Start(_threadParameters);
}
void Update() void Update()
{ {
this.UpdateJobsInternal(); this.UpdateJobsInternal();