Hi
The documentation of OnValidate states that it is an editor only build method.
Is there any reason all the OnValidates in a project are still included in the builds, even with Managed Code Stripping set to high?
Thanks
Hi
The documentation of OnValidate states that it is an editor only build method.
Is there any reason all the OnValidates in a project are still included in the builds, even with Managed Code Stripping set to high?
Thanks
Well the docs donât say anything about it being an âeditor only build methodâ it states itâs only called in the editor.
None of Unityâs magic methods are stripped out from builds, including editor-centric ones like OnDrawGizmos. If you donât want it in a build, surround it in #if UNITY_EDITOR
pre-processor directives, like normal.
Hi @spiney199 . Thanks for your answer.
Thatâs what I do already, but I was wondering why making this needed in the first place.
True, but my question was why âonly called in the editorâ would not lead to âeditor only build methodâ.
I find that it is a missed opportunity from Unity to reduce build sizes.
I get that changing in the future the default behavior (to make unity strip these methods) might break existing projects, thus making this decision a bad one. But I think that allowing this behavior as part of Managed Code Stripping set to high (which is aggressive already to the point of potentially breaking projects) can be a good idea. That way, people wanting minimal builds at all cost can benefit from this behavior.
Code is, by a country mile, the tiniest part of a build. I doubt stripping a few lines is going to make a noticeable difference. A single texture file could easily outsize all your .dll files.
Extensive validation, gizmos, etc, should be handled with custom editors anyway. That way none of them will make it into a build.