gilzoide / unity-update-manager

Simple to use Update Manager pattern for Unity + Jobified Update for MonoBehaviours and pure C# classes alike
The Unlicense
93 stars 10 forks source link

Exception in UpdateManager when Domain- and Scenereload is disabled #19

Open HanHangit opened 5 months ago

HanHangit commented 5 months ago

Hello,

we have Domainreload and Scenereload disabled in our project and got a problem with the Update-Manager. Problem is, the UpdateManager gets destroy on [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] but the bool in ApplicationUtils.IsQuitting is still true so the RegisterInManager throws an Exception that the UpdaterManager is destroyed but i try to access it.

Problem is that our scripts try to register into the manager before the ApplicationUtils resets the IsQuitting bool to false from the last playmode session.

I fixed the problem by adding the RuntimeInitializeLoadType.SubsystemRegistration to the RuntimeInitializeOnLoadMethod in the ApplicationUtils class, so the bool is false when the next scripts Register during OnEnable.

Maybe it would be a good change for people who have Domain and SceneReload disabled.

Cheers, Johannes

gilzoide commented 5 months ago

Hey @HanHangit, thanks for the report! Oh my, sorry about that. I've never disabled Domain Reload nor Scene Reload, so I hadn't tested this scenario.

I fixed the problem by adding the RuntimeInitializeLoadType.SubsystemRegistration to the RuntimeInitializeOnLoadMethod in the ApplicationUtils class, so the bool is false when the next scripts Register during OnEnable.

Seems like a good solution, I see no concerns there. If you want, create a PR with your fix, I'll be glad to merge it =] Otherwise, I can fix here. Either way, next version should have this problem fixed!