1. 程式人生 > >【unity外掛】Tiled2Unity-非常方便的將Tiled匯入到unity3d

【unity外掛】Tiled2Unity-非常方便的將Tiled匯入到unity3d

在找tiled for unity相關外掛的時候,偶然發現一個非常棒的外掛,就是Tiled2Unity(點選進入官網),並且這款外掛完全免費!!!而且支援的功能真是太良心了!在Tiled編輯好地圖之後一鍵傳送到unity,非常之方便。而且提供的unity指令碼拓展性非常強。



支援的功能如下:

Features:

  • Builds a Unity prefab out of your TMX map file
  • Supports all TMX layer formats (XML, CSV, Base64, gzip/zlib compressed)
  • Multiple layers and tilesets supported
  • Exports Object Layer as polygons, polylines, rectangles, circles
  • Tile Layer collisions supported (with slopes, odd-shaped polygons)
  • Polygon colliders can be concave, have holes, and be composed of separate polygons
  • Can assign Tag, Sorting Layer, Order in Layer, and (Physics) Layer of exported GameObject
    s through properties in Tiled
  • Support for customized creation of Unity Prefabs
  • Easy to use: In most cases, you simply export a TMX file into your Unity project and place the automatically generated prefab in your scene – no further edits needed

使用說明和功能介紹看這裡:點我

使用示例看這裡:點我

Learning Tiled2Unity

I’ve tried to make Tiled2Unity simple to use and understand. Here’s some links that may help you out:

  • Introduction: Use the test TMX files supplied with Tiled2Unity to create two simple scenes in your Unity project (one with sloped collision).
  • Tiled2Unity Scale: By default, Unity 2D sprites use a coordinate system where 100 pixels equals 1 unit in Unity. I think that’s crazy but this link will show you how to live in that world.
  • Mega Dad Adventures: A good number of “advanced” examples of using Tiled2Unity in your Unity projects. Set tags and layers on your imported prefabs and add custom, game-specific behavior.
  • Tile EdgeCollider2D Support: Shows you how you can use polylines in the Tile Collision Editor to export EdgeCollider2D objects in your Unity prefab.

ps:支援的unity引數列表

Here’s the list of the properties we can set in Tiled that the Tiled2Unity exporter looks for when constructing a prefab:

Prefab object properties (set in TMX file for each layer/object)

  • unity:sortingLayerName
  • unity:sortingOrder
  • unity:layer (Layer is such an overloaded term. In Unity it means the “physics” layer.)
  • unity:tag
  • unity:scale
  • unity:isTrigger
  • unity:ignore
  • unity:collisionOnly
  • unity:resource
      (Other properties are exported for custom scripting in your Unity project)

2015.11.27更新 ●似乎不支援圖塊的繪製偏移引數
2016.3.31更新 ★unity:ignore引數說明:  false-不忽略 true-忽略整個圖層(也就是不傳送這個圖層到unity)  collision-只忽略碰撞,但是匯出圖形  visual-只忽略圖形但是匯出碰撞

使用方法:

1、安裝Tiled.exe和Tiled2Unity.exe 2、開啟Tiled,編輯命令,新增新命令,後面的連結改為unity工程的連結(unity必須匯入好Tiled2Unity外掛) 官網沒寫清楚,一定要寫到Assets\Tiled2Unity目錄
"c:\Program Files (x86)\Tiled2Unity\Tiled2Unity.exe" %mapfile c:\MyUnity\Assets\Tiled2Unity

3、編輯完Tiled地圖,按f5使用命令列匯入