MirageNet/Mirage

Store Log settings outside asset folder

James-Frowen opened this issue · 2 comments

From discussion on discord, seems it would be preferred to save settings outside the asset folder

Parts that need doing for this

  • Save outside (under Project settings folder)
  • Load in editor
  • Load at runtime

From discord about how to save outside asset folder

Hertzole — Today at 14:19
To start, your scriptable object needs to initialize itself outside the editor only. That can be achieved with OnEnable.
https://github.com/Hertzole/advanced-level-editor/blob/master/Packages/se.hertzole.ale/Runtime/Common/Easy%20Project%20Settings/RuntimeProjectSettings.cs#L66
But you still need a simple way of getting it. So if you're in the editor, you have to load it from the project settings, else just use the static instance.
https://github.com/Hertzole/advanced-level-editor/blob/master/Packages/se.hertzole.ale/Runtime/Common/Easy%20Project%20Settings/RuntimeProjectSettings.cs#L24
The loading part: https://github.com/Hertzole/advanced-level-editor/blob/master/Packages/se.hertzole.ale/Runtime/Common/Easy%20Project%20Settings/ProjectSettingsHelper.cs#L30

Then finally comes the building. https://github.com/Hertzole/advanced-level-editor/blob/master/Packages/se.hertzole.ale/Runtime/Common/Easy%20Project%20Settings/ProjectSettingsBuildProcessor.cs#L21
It just creates the asset in the root folder based on the package name. So like "com.miragenet.mirage.Settings.asset". Then it adds that to the preloaded/keep alive assets list. Then after build, it removes them. It's very important that it happens with a delay (as noted in the code) for it to actually work.
HOWEVER! My implementation is still flawed there. I just revert the whole list but I should be going through it and remove just my objects to make it work with other assets that do something similar. So just go through the current list after build, check if it's the same type and then remove it, instead of just saving the original list and setting that.

There's still the issue that if you cancel a build and it already has created the scriptable object in the assets folder, it does not get removed. I've yet to solve this issue...

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 14 days.