Seanba / Tiled2Unity

Export Tiled Map Editor (TMX) files into Unity
Other
497 stars 120 forks source link

Sorting Layer Changes when pulled from GitHub. #103

Closed dkoester306 closed 7 years ago

dkoester306 commented 7 years ago

I've been working on a project with some friends and we decided to use Tiled and Tiled2Unity for the map. One issue that I'm having is that whenever someone downloads the repository for the first time and opens the map, the sorting order of certain layers are changed. When the project is opened for the first time, GitHub shows that there are at least 3 changes to the map prefab and a couple other things. I've found that undoing these changes and reloading the project fixes this issue for right now. I was wondering if anyone has ever experienced this issue? And if someone might know a fix to stop this, it would be really appreciated! Please leave a response, or if you have questions regarding the post.

Seanba commented 7 years ago

I haven't experienced this issue. Are you using "Visible Meta Files" in your editor settings (in Unity)? It sounds to me like collaborators are having to re-import any exported *.tiled2unity.xml files that are in your repository. Also, make sure that everyone is on the same version of Unity. Otherwise, all your content (textures, models, etc.) will be re-imported (and not just the stuff in Tiled2Unity).

This link may be helpful: https://docs.unity3d.com/Manual/Versioncontrolintegration.html

dkoester306 commented 7 years ago

Thanks for responding to quickly. So I do have "Visible Meta Files" enabled in my editor, so I'm not sure what's causing it. I'm going to include some screenshots of what I'm experiencing in both GitHub and Unity, in case that might help this issue. I'm not sure if this is a problem with my .gitignore or not either.

What it looks like before the fix. capture

The strange thing is that my third layer "Pond" saves as my "floor" sorting layer but the rest don't. capture4 capture5 capture6

After exiting unity and discarding these changes, my thing is fixed. capture2

What it looks like after the fix, like how it should be. capture7

Seanba commented 7 years ago

Could you grant me temporary access to your Github? It would help me understand what's going on here a bit better.

dkoester306 commented 7 years ago

Just did, let me know what you find!

On Tue, May 30, 2017 at 4:08 PM, Seanba notifications@github.com wrote:

Could you grant me temporary access to your Github? It would help me understand what's going on here a bit better.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Seanba/Tiled2Unity/issues/103#issuecomment-305008808, or mute the thread https://github.com/notifications/unsubscribe-auth/AZg0VbUEIhBMXqHaCZoWqvd6H1HRBCUoks5r_IVQgaJpZM4Npzso .

Seanba commented 7 years ago

I'm looking at your PlaceHolderMap.tiled2Unity.xml file (this is what Tiled2Unity scripts use to create your prefab) and looks like none of these Tile Layers:

... are using the "floor" sorting layer so they revert to "Default". (They do have sorting orders of 0, 1, and 2, respectively, however.)

Also, the map looks right to me when I load the project for the first time ...

image

However, your map prefab in your TestScene scene has "local" changes to it. In other words, someone may have changed the "Pond" sorting layer to "Floor" by hand and then submitted it to your depot. Pressing "Revert" on the PlaceHolderMap game object in the Inspector window undoes these changes and also "fixes" the sorting layers ...

image

Do you have some people on your team on Mac/Unix and others on Windows? It looks like this map was first exported (and submitted) through a OS that uses Mac/Linux line-endings. That is why your material file has local changes on it, btw.

dkoester306 commented 7 years ago

First off, I'm not sure why GitHub isn't saving the changes to the sorting layers, because I make sure they are changed to the "Floor" sorting layer before I push.

Also, I'm not sure how you get the map to look like that right when it loads up, because whenever I load the map for the first time it looks like this. image

No one on my team is using Max/Unix, so I'm not sure why the map is exporting like it is for those platforms. At this point I'm not sure if it's just the way I have my unity setup. So, I might try this on a different computer and see if it works any differently. Not sure if there is anything that can be done on your end. I still appreciate all of the help you have provided so far.

Also, I'm not sure if the issue comes from having the wrong software installed, and it causing issues. This goes for Unity, Tiled, and Tiled2Unity

Seanba commented 7 years ago

When syncing up for the first time your Unity project has to build out the "Library" folder. This will also happen when you change build target platforms - like from Windows to iPhone or Playstation 4. This forces users to re-import all their resources, including any *.tiled2unity.xml files.

This in turn will recreate the map prefab that you submitted. So, any changes you made to the prefab, like changing the sorting layer, will be undone.

So, what you want to do is have Tiled2Unity automatically set the sorting layer for you when it exports a map. This can be done through the unity:sortingLayerName custom property in Tiled (see this link: http://www.seanba.com/megadadadventures.html)

So, long story short, if you set up your map, in Tiled, with the proper attributes then re-export then everything should be okay.

dkoester306 commented 7 years ago

Hey Seanba,

That worked thank you so much you're a livesaver!! I never would have though to make custom attributes to my Tiled project in order to get it working. Thanks for all your help!!

Seanba commented 7 years ago

Glad it worked for you. (And sorry for the late reply)