question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TileFlags are serialized wastefully

See original GitHub issue

After 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:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Seanbacommented, Jul 20, 2019

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 the Override dropdown in the inspector …

image

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.

1reaction
Seanbacommented, Jul 17, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found