TileFlags are serialized wastefully
See original GitHub issueAfter upgrading from SuperTiled2Unity 1.4.6 to 1.5.1 our scene file grew in size from 241 kB to 7 MB. The extra space is used up by serialized TileFlag data that looks like this:
- target: {fileID: -2874227231539500416, guid: b6ea4e7e6d4845f4ab566848146f0f2d,
type: 3}
propertyPath: m_Tiles.Array.data[16792].second.m_TileFlags
value: 0
objectReference: {fileID: 0}
- target: {fileID: -2874227231539500416, guid: b6ea4e7e6d4845f4ab566848146f0f2d,
type: 3}
propertyPath: m_Tiles.Array.data[16793].second.m_TileFlags
value: 0
objectReference: {fileID: 0}
- target: {fileID: -2874227231539500416, guid: b6ea4e7e6d4845f4ab566848146f0f2d,
type: 3}
propertyPath: m_Tiles.Array.data[16794].second.m_TileFlags
value: 0
objectReference: {fileID: 0}
It seems to use five lines of YAML to store the flags for one tile of the tilemap. This not only looks incredibly wasteful but makes it quite difficult to try to understand what changes I’m committing to my scene files. Even with small changes of the tilemap, the diff of the scene file is full of these serialized zero flags.
This happens in version 1.5.0 but not in 1.4.6. I wish the serialization could be done in a much more compact format.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
TileFlags - Scripting API
Flags controlling behavior for the TileBase. Properties. None, No TileFlags are set. LockColor, TileBase locks any color set by brushes or the user ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi again, @vvnurmi. Version 1.5.2 fixes this issue. It turns out that under some conditions Unity was saving out a ton of “prefab instance modifications” to scenes - even if the “modifications” were the same as the original value on a prefab.
Luckily, changing the way a Tiled Map was saved to a scripted importer fixed the problem. In my case, my test scene went from 400kb to 11kb. I expect you will have similar gains.
There is one caveat though: These modifications are now baked into your scene and have to be removed. Normally, you can do this through the
Revert All
button in theOverride
dropdown in the inspector …However, there is currently a bug in most current Unity versions that is crashing if you try to do this.
But, you can fix this by deleting the prefab instance in your scene and replacing it with a new one. If you happen to be on an alpha or beta build of Unity (which I don’t recommend, honestly) then you may be okay with just reverting the modifications in your scene. Thanks.
Hi again, @vvnurmi. Now I am seeing of this behavior and it is related to prefab modifications but I’ll have to dig down and try to figure out what is going on. My apologies I may not get to it for a couple of days.