Closed SilentSin closed 6 years ago
I do not see anything in the log in a development build in Standalone in 2017.4 This should, at the very least, remove the memory cost at runtime, unless I am very much mistaken.
No, you're right, it seems they did implement re-serialization based on the runtime class structure since I last checked (which was like, back in Unity 4 or something) because I'm not getting the same old error and I can't detect any difference in build size or runtime resource load time when creating a float[1024 * 1024] in a #if UNITY_EDITOR region (which does clearly affect the size of the prefab asset in the editor).
And perfect timing too. I was just about to implement a rather hacky workaround for serializing editor-only fields.
This is great news! I also had my fair share of workarounds for that issue.
I remember only ever actually seeing the warnings on WebGL builds. It would spam the console hard when the serialized layout didn't match between the editor and a build.
There's a problem in GuidReference.cs:
This will still include serialized data for those fields in a build and will throw warnings in the log about the serialized data not matching the class.
Being able to make editor-only fields like that would be super useful but would require low level engine modifications. Even if we have to write [SerializeField(EditorOnly = true)] or something since reflection can't detect the #if on its own. Otherwise the build process would need to re-serialize everything based on the runtime class structure (possible, but would extend build times).
The only way to currently serialize editor-only data on a component is to have a whole separate component and set its hideFlags to DontSaveInBuild. Also note that this approach doesn't work if the component is saved in a prefab because the hideFlags get ignored.