Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TileFlags are serialized wastefully #85

Closed
vvnurmi opened this issue Jul 17, 2019 · 5 comments
Closed

TileFlags are serialized wastefully #85

vvnurmi opened this issue Jul 17, 2019 · 5 comments

Comments

@vvnurmi
Copy link
Contributor

vvnurmi commented Jul 17, 2019

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.

@Seanba
Copy link
Owner

Seanba commented Jul 17, 2019

Hi there, @vvnurmi. I'm having difficulty reproducing this behavior. Is it possible that the TMX maps in your scene have had their connection to the TMX prefabs broken? In other words, I wonder if the maps in your scene are no longer prefab instances but instead are the fully-formed game objects?

If you can send me your Unity Project (email: sean@seanba.com) it may help me track down what has happened. Thanks.

@Seanba
Copy link
Owner

Seanba commented 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.

Seanba added a commit that referenced this issue Jul 20, 2019
Potential fix for long-standing issue #5 using AssetImportContext to reduce wild number of prefab modifications on our collision geometry. (Switching generation type from Manual to Synchronous also was a contributing factor).

Also, fix for issue #85 which was the main impetus of this bug as prefab modifications were being recorded in our scenes for every tile transformation.

Bumped up to version 1.5.2
@Seanba
Copy link
Owner

Seanba commented 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.

@Seanba Seanba closed this as completed Jul 20, 2019
@Seanba
Copy link
Owner

Seanba commented Jul 29, 2019

Someone recently pointed out this fix crashes projects using 2018.3 so I'm going to re-open this issue until I have the fix conditionally compiled out.

Sadly, this means you'll have to be on Unity 2019.1 or later to get the benefit of the fix.

@Seanba Seanba reopened this Jul 29, 2019
@Seanba
Copy link
Owner

Seanba commented Jul 29, 2019

This is "fixed" with version 1.5.4 of SuperTiled2Unity but unfortunately means users on Unity 2018.3 will not have these prefab override fixes.

@Seanba Seanba closed this as completed Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants