Seanba / Tiled2Unity

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

Pixel Snap default? #171

Closed snixer724 closed 5 years ago

snixer724 commented 6 years ago

Hey Seanba,

When using a combination of both Tiled and Tiled2Unity it seems like every map we throw into the game resets the pixel snap to off. Do you know if this is a tiled or tiled2unity thing? Is there a workaround for this? I have to set the pixel snap in the Tiled2Unity -> materials folder every map :(

snixer724 commented 6 years ago

Any idea?

snixer724 commented 6 years ago

Is there a way we can set the PIXELSNAP_ON to default? In our commits to our project (when turning on pixel snap), the diff looks like the shader gets the "PIXELSNAP_ON" set and pixel snap goes from a value of 0 -> 1

Seanba commented 6 years ago

Hi there. Sorry I took so long to respond. I'm in the process of phasing out Tiled2Unity and replacing it with something totally new that exports Tiled maps to the newer Tilemap-based tech in Unity 2018.

Anyways, you can accomplish this through script where materials are created like so:

            // Force pixel snap to be always on
            material.SetFloat("PixelSnap", 1.0f);

I've attached the file that will do this for you. Remove the 'txt' extension and replace your version of ImportTiled2Unity.Xml.cs with this one and it should work. You will need to re-export your maps, however.

ImportTiled2Unity.Xml .cs.txt

snixer724 commented 5 years ago

Seanba you are amazing. Thank you.