Is it normal that now with 2019.3 onValidate gets called at build time for each scene?
It is quite annoying and have to revise a lot of code.
If the behavior has changed between versions, then you probably found a regression. In this case, please submit a bug-report and leave the Case number here for Unity staff to pick up.
Before doing a bug report which is quite time consuming(unless it is fine without repro project) I want to know if it is expected.
I have already some bugs report open since many years, so I would like to avoid reporting if not absolutely necessary.
I am pretty sure this has not changed and OnValidate has always been called each time a scene was opened during player building.
So I am curious what you have noticed as a change?
Strange. I have some script doing procedural generation on onValidate because I didn’t bother to create an editor script, but I never noticed its messages while doing a build.
Maybe before I had just regular message, while now I introduced some error messages?
It’s really strange I never noticed it, because some of them are quite verbose.
Maybe before you weren’t showing the messages on the console?
Well, if the object isn’t currently active and loaded, it won’t trigger so perhaps that’s why you didn’t see it before. It has always happened to me though, when building a scene with such an object present.
(And it should fire because during build, developers are able to run a number of scripts and utilities to change the output that gets built, though I haven’t personally used OnValidate for these purposes)
If you guys say so I believe it.
Why it need to get called every time btw?
It is done every time a scene is loaded or a prefab asset is loaded, to ensure the scene is in a valid state. Imagine a bad merge of a scene causing dangling components or broken transform hierarchies, if we simply ignore that during the build process it would be pretty bad.