Deadcows/MyBox

Please consider not running MyBox editor routines in play mode

Tommigun1980 opened this issue · 3 comments

Profiling the game is a bit cumbersome as MyBox seems to initialise itself as if it was running in editor mode whenever Play in Editor is pressed. It would be great if MyBox would be latent if the user is running in the editor but is 'in or entering the play mode'.

GetMyBoxInstalledVersion() seems to be quite a big culprit. Here's a screenshot of what MyBox is up to when a game is started in the editor:
Screenshot 2022-05-01 at 1 43 38

Thank you!

Sorry for the late responce.
It is actually should not be happening.
Update check should be triggered only when editor opened (one time during editor application lifetime) since MyBox 1.7.0 release.

Although this might occure if MyBoxWindow is opened when you enter in playmode, but probably it's not the case. Who need this window to be opened constantly?

So, make sure that MyBoxWindow is not opened. Also consider to reinstall MyBox to get unreleased updates.
And also you may to disable Update Checks here is case this issue persists.

image

Please let me know if your problem is solved

Hi @Deadcows and thank you so much for the reply!

I did not have that window opened but it seems as MyBox is doing the update check every time when entering play mode (and presumably when exiting play mode as well). This makes the play button a bit sluggish as so much is going on there.

If the update check is behind an InitializeOnLoad attribute (or similar) those get executed every time a domain reload happens, so the update checks are probably happening also when sources are saved. I could turn off 'Check for Updates' locally, but then would need to instruct every team member to do the same (or make a script that forcefully turns it off for everyone on every script compilation) so in that regard it'd be great if this could get fixed.

Thank you again for such a fantastic library!

If the update check is behind an InitializeOnLoad attribute (or similar) those get executed every time a domain reload happens

It was quite tricky to solve. I figured out that creation of empty ScriptableObject might solve the issue with domain reload. You may utilize this using MyEditorEvents.OnEditorStarts event

I could turn off 'Check for Updates' locally, but then would need to instruct every team member to do the same

To prevent this MyBoxSettings.asset is stored in ProjectSettings folder, so this change should be tracked with your version control system

While I wrote this I decided to run a few tests and indeed MyEditorEvents.OnEditorStarts is false triggered from time to time. Maybe something is changed in Unity over the years and used hack is not valid anymore.
Anyways, in pursuite of fixing it I found out about utility class SessionState. Don't know how I missed that, this class was in Unity for the last five years, seems very useful!

So, now it should be fixed! Thanks. Learned something useful today because of you 😁