Eklavyaa
Eklavyaa

Reputation: 380

Need to use Tiled Map editor with Unity 4.3.4

I shifted to unity few weeks ago. I am developing a 2D platformer. For creating the maps I am using Tiled map editor from www.mapeditor.org . I have created a basic map. Included the tileSheet png and the .tmx file (saved as XML) in the Assets of the project. I am able to read the XML , that is all the gid's. But I don't know how to access a particular portion(tile) from the tileSheet corresponding to a gid.

I think for this I need to load sprite in the memory and select a tile (by specifying Height and width and coords) from texture memory to display it on screen. As given here :http://gamedevelopment.tutsplus.com/tutorials/parsing-and-rendering-tiled-tmx-format-maps-in-your-own-game-engine--gamedev-3104 but its for flash , how I can achieve same thing in Unity using C#. Notice the copyPixel stuff in the flash code. I thought I could use ReadPixels but it is used for reading from screen only not the texture memory.

Thanks.

Upvotes: 2

Views: 8073

Answers (2)

Seanba
Seanba

Reputation: 141

If you're working in Windows then the Tiled2Unity Utility sounds like it will fit your needs. It exports Object Layers and was made with Unity 4.3 features in mind.

(Full disclosure: I'm the author of Tiled2Unity)

EDIT: Tiled2Unity is available for Mac users as well now. There is a command-line version for Linux users. (all free)

Upvotes: 6

Jorge
Jorge

Reputation: 21

If you can describe more carefully your problem and what you are trying to do, maybe myself or someone can help you better, for example what exactly do you mean by "load a sprite into memory"? Or "select a tile"? Copying pixel data is SLOWWW, and hopefully you don't mean to be doing this in real time.

Here is my real advice though:

Have you checked out UTiled? It does tiled maps in 2D in Unity so I think it already does what you want and it's free. There is also UniTMX... free. There is also 'Tiled Tilemaps'... which is like $2. I also built a system that can also do what I think you are trying to do (your link is broken, so I can't be sure).
The system I built is called 'Tiled to Unity' (you can search it in youtube to see if it does what you want). It allows you to attach gameObjects to tiles and have tile variants, and can do 3D tiles. Anyway, trying to roll your own pipeline from Tiled into Unity is a ton of work, and with these tools available, I think it is almost certainly unnecessary... That's just imo.

Upvotes: 2

Related Questions