-
Notifications
You must be signed in to change notification settings - Fork 54
Description
Hello Devs.
First of thanks for the great tool. We intergrated this in our big project.
But this caused also many problems. I had to completly rewrite many parts.
Problems:
- OnValidate.
- I don't know why but OnValidate works also even Unity did not finish the Compiling and also works while reloading (if you add assets etc). It is like when scripts gets dragged into the project and OnValidate starts to work without compiling it. And this caused problems when we switch branches. When we switch between branches it still creates the Unity-Theme Database asset, even if the branch has no unity-themes included. It is because OnValidate gets executed in every situation. Same also if you switch from branch to a branch with unity-themes included.. it will overwrite the database because it was not ready but still starts to call functions... really weird.
- Fix: We added UnityEditor.EditorApplication.isCompiling and isUpdating check. This helped only on few situation but not completly
- Singleton
- Like I said if OnValidate or others fires -> GetOrCreateInstance function will be also used. But unity shows error AssetDatabase is not ready yet to save something or load which leads to "No database found" and will create default values. I lost often with this my database because its overwrites with default values. This totally broke our entire project because prefabs was dirty and saved. I didn't get why lol. The only help was to gooo far back where unity-themes wasn't in the branch and it had old colors applied etc.
- Fix: Also add isCompiling and isUpdating check. If true GetOrCreateInstance will return and stop.
But those alone did not help. In Themes.cs we also added to OnValidate() isCompiling and isUpdating.
So we started completly to rewrite. OnValidate and OnEnable is not allowed to to activate and create singleton.
So we complety rewrote the logic. We added event onInitialized. We also use InitializeOnLoadMethod and RuntimeInitializeOnLoadMethod which will run if application runs or editor starts to load methods and call there GetOrCreateInstance() when this happens also onInitialized gets invoked which enables Binders to work (they also can check IsInitialized).
Since this we didn't notice any problems.
I wonder why never people wrote about this or are most of them not using multile branches? lol.