Giter Club home page Giter Club logo

tiled2unity's Introduction

tiled2unity's People

Contributors

bjorn avatar seanb-22ct avatar seanba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tiled2unity's Issues

Can only import one Tiled Map.

Hi I've used Tiled2Unity before with no problem.

I recently started a new project on Unity and I imported one map from Tiled with no trouble. The problem began when I imported a second map for Tiled. When I imported a second map the first one became pink, so I re- imported the first map and then the second one turned pink. And it just keeps going like that.

Do you know any potential fixes to this bug?

Using Unity 5.3.5 p2 and most recent version of Tiled2Unity

Better way to create objects from prefabs already available in the project

I wonder if there is a better way to add a custom property to some objects in an objects layer to get Tiled2Unity to creater the GameObjects from some already createrd prefabs.

Say we have the property prefab with the value Cannon.

screen shot 2016-09-24 at 12 36 43 pm

I modified the script ImportTiled2Unity.Mesh.cs where it creates the GameObject to look for the value in the property prefab, then create the GameObject from the prefabs already available in my Assets/Prefabs folder. Something like follows:

string prefabName = (from p in goXml.Elements("Property") where p.Attribute("name").Value == "prefab" select p.Attribute("value").Value).FirstOrDefault();

if (prefabName != null) {
    string prefabPath = "Assets/Prefabs/" + prefabName + ".prefab";
    UnityEngine.Object prefab = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject));
    if (prefab != null) {
        GameObject prefabInstance = (GameObject)GameObject.Instantiate(prefab);
        prefabInstance.name = prefab.name;
        child = prefabInstance;
    }
}

if (child == null) {
    child = new GameObject();
}

I wonder if there is a beter way to do it. Something that doesn't imply modifieng the scripts in TiledToUnity

Keep up the good word,

Regards.

Question: Exported Map is blurry; May I ask how I can fix this?

Again, thank you for distributing this amazing assist tool.

I exported map with Tiled2Unity, but result is not quite good...
I mean, it works but I want it to be more... clearly.

This is my fan-game's intro stage map.

and this is result that imported in Unity.

(I can send you my .tmx file if you want to check it yourself)
You can see that the original image and sprites of objects(Rockman X, Mettool, Walkcannon) inside game are quite clear, while background image is not. (It's blurry, fuzzy, scattered, and unfocused..? I couldn't find the word that explain this situation exactly)

And, I found about post that this might be because the image that I use was too big.
http://discourse.mapeditor.org/t/large-tiled-maps-look-unfocused-when-imported-to-unity/219

But I'm not good at English and I couldn't find out how to fix this problem.

So, I ask for you how I can solve this problem.
Sincerely, I really appreciate you! :)

Unity Version: 5.4.0

End of issue.

some render artifacts (lines) in imported prefab

Hi, Sean.
I am so much grateful to you for the this importer. But recently i discovered some problem after import *.tmx. In my unity project i saw a long line on imported prefab, and they were on
on the border of a title compound. i am not possible describe it, you could see in pictures
The first pic is view in Unity proj
unity_viev
And second pictures is TiledEditor view
tiled_viev
Pls take me some advice about fix it.
And i want ask you about custom value "Vertex scale" - its field is not save specified value: I wrote "0.01" and pressed BigButExport. Export was been done, but in log-line i saw vertex-scale value as "1.0" - what i didi wrong?

Tiled2Unity Not Working

When i transfer the tiled file to unity it just comes in a text file i dont know how to fix i follow all the correct steps but it wont work please help me

Multi-platform Support

With the Unity editor running on OSX (and now Linux), and tiled as well, it would be totally awesome to be able to run this under mono to support other platforms as well.

There are sort of two approaches I can think of to doing this:

  1. Rewrite the UI using Xamarin.forms
  2. Provide a command-line only binary that doesn't depend on windows specific .net APIs (e.g., WPF/PresentationCore)

Question: How to attach Custom MonoBehaviour Script to Tiled Object?

First, thank you for distributing this amazing assist tool.
I'm also one of the big fan of the greatest game Rockman(Megaman), so I'm making a fan game (X-series) too.

I want to attach custom script to imported GameObject, but I couldn't find about how to do this.
In additional, I want to set default value of it. (want to use custom properties)

Since it is not enough to explain my situation because of my poor English, I'll explain more in detail.

I wrote code class "CameraZone5Script". This class has several public boolean fields: _isTopBounded, _isLeftBounded, _isRightBounded, _isBottomBounded, etc.
In Tiled, I created Object Layer "CameraZone", created and checked custom properties like this.

But it is not applied appropriately in Unity (5.3.5), so please, I want to hear some advices.

Again, thanks to your good program.

Question: Re-mapping tile art once in unity

I was reading the towerfall dev blog post about auto-tiling (http://towerfall.tumblr.com/post/98906957031/detailing-process-i-still-want-to-prototype-a-new).

I was curious if it's possible to use tiled2unity to create a mesh using some base tiles, which can then be mapped to different tile "themes" in unity. E.g. You could create 5 "theme" tilesheets, where each type of tile is in the same corresponding place in the tilesheet. I'm curious if I can swap out the underlying tile texture image once in unity to change the style of the tiles.

Thoughts? and Thanks! Love the tool

Map and map tilesets not importing into Unity

Alright, so things used to work great, until I got a new computer and re-downloaded newer versions of Tiled, Tiled2Unity, and Unity itself. Now I can seem to get Tiled2Unity to work. The *.tiled2unity.xml file exports just fine, but that's it. Nothing in Unity shows up, the prefabs, materials, nothing. I also get an error in Unity when I export it:
Importing 'Assets/Tiled2Unity/Imported/Level1.tiled2unity.xml' but Tiled2Unity files cannot be imported with the WebPlayer[deprecated] platform. However, You can use Tiled2Unity prefabs imported by another platform. UnityEngine.Debug:LogWarning(Object) Tiled2Unity.TiledAssetPostProcessor:UseThisImporter(String) (at Assets/Tiled2Unity/Scripts/Editor/TiledAssetPostProcessor.cs:46) Tiled2Unity.TiledAssetPostProcessor:OnPostprocessAllAssets(String[], String[], String[], String[]) (at Assets/Tiled2Unity/Scripts/Editor/TiledAssetPostProcessor.cs:65) UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])

Anyway to fix this?

Question: Tips for specifying collision region for many many tile types?

With some tile art, there may be tons of tiles that all have a simple square (100% filled) collision area. Do you have tips, ideas for rapidly applying the collision area to all those tiles at once? Same goes for simple ramps, etc.

One thought was using Tiled's auto-mapping feature, and using a separate collision layer, but tiled2unity seems geared towards mapping the layer and collision areas into the same mesh in unity. Thoughts?

Stuck importing map with unity:resource True

Hi, I've been using Tiled2Unity with some procedural generation, and for maps to be generated in execution, I needed tmx processed prefabs to be stored in Resources folder, but something happens and importing gets stuck on "Create prefab: XX".

I've been debugging for a while, and it seems that in "TiledAssetPostProcessor.OnPostprocessAllAssets()", last call of the loop is for the prefab itself. If it is processed correctly, then "ImportFinished" is called, but this doesn't happen in this case.

I would take a look at "TiledAssetPostProcessor.UseThisImporter()", as for the prefab case with unity:resource=True, the folder path (exportMarkerPath) is something like: "PROJECTROOT\Assets\Tiled2Unity\Prefabs\Resources..\Tiled2Unity.export.txt", which does not consider the "Resources" case, and seems to look for the export.txt inside "Prefabs" instead of inside "Tiled2Unity".

I'm going to hack my code to avoid this problem, but as I don't know this library enough, for now I will not suggest a pull request until I'm 100% sure it doesn't break anything. In any case, I'm sure you guys will find a better and more general solution :)

Just in case, I'm using unity 5.3.1f1, Tiled2Unity-1.0.1.1, and Tiled 0.14.2

Move some comments to wiki

Examples and instructions should be moved to a wiki. The bad thing about putting it inside the source code is that people have to look for it. In a wiki, everything is better organized.

An example is ICustomTiledImporter.cs containing the following code:

// Examples
/*
[Tiled2Unity.CustomTiledImporter]
class CustomImporterAddComponent : Tiled2Unity.ICustomTiledImporter
{
    public void HandleCustomProperties(UnityEngine.GameObject gameObject,
        IDictionary<string, string> props)
    {
        // Simply add a component to our GameObject
        if (props.ContainsKey("AddComp"))
        {
            gameObject.AddComponent(props["AddComp"]);
        }
    }


    public void CustomizePrefab(GameObject prefab)
    {
        // Do nothing
    }
}
*/

Importing with shared assets makes all maps lose material references

Affected version: 1.0.6.0

How to reproduce

  • Have two maps that use the same tsx tileset, with the same textures. Say, Map1 and Map2.
  • Export Map1 and let Unity import it. Verify that it imported correctly.
  • Now export Map2 and let Unity import it.
  • Map1 has now lost all of its material references.

Fix
During the xml import phase, first we check if an asset with the given name was already created. If it was created, we replace it instead of re-creating it from scratch. This preserves all references to the asset (preserves the meta files).

If anyone ends up having to deal with this, add this helper function to the HelperExtensions {} class on the ImportUtils.cs file:

    public static T CreateOrReplaceAsset<T>(T asset, string path) where T : UnityEngine.Object {
        var existingAsset = AssetDatabase.LoadAssetAtPath<T>(path);

        if (existingAsset == null) {
            AssetDatabase.CreateAsset(asset, path);
            existingAsset = asset;
        } else {
            EditorUtility.CopySerialized(asset, existingAsset);
        }

        return existingAsset;
    }

Now, in the ImportTiled2Unity.Xml.cs file, replace AssetDatabase.Create calls with HelperExtensions.CreateOrReplaceAsset


Drawbacks

Suppose you're actually using two maps that have different textures with the same name. For example, in each map we have a background tileset, with a bg1.png tile (or tilesheet).
Using this fix will make the both maps display the bg1.png of the last imported map. This is undesirable, as the images are most likely different.

Note that, without this fix, the first map to be imported would display nothing for bg1.png, as it would have lost the reference altogether.

An alternative fix would be having each imported map have its own material and textures, completely independent of each other, possibly with a suffix in the materials and textures names. Of course, doing this could end up bloating the game since we could end up with lots of duplication.

In my case, the best alternative was to use the presented fix and be careful not to name different things with the same name, even across maps.

Not finding map after export

When I export my tiled map via tiled to Unity in Unity 5.0 there is nothing under prefabs I can drag and drop into Unity.

I finish my map in tiled, save the tiled file (.tmx), open unity, open your program, click Help > Import... then I click File > Open..., chose the map, choose the Tiled2Unity.export.txt as the export destination and click the Big Export Button.
Going back into Unity I find nothing under prefabs to import.

Am I doing something wrong?

Properties for individual tiles

Currently, looks like properties (unity:layer, unity:tag, etc) are only grabbed for actual tile/object layers. I'm currently trying to build our game in such a way that we can do item/enemy placement entirely from within Tiled, but having so many layers becomes cumbersome.

Would be really cool if I could just tag my individual tiles with the unity:tag property (ie: unity:tag = coinSpawner, enemySpawner, etc), and then paint them into a single layer

Not sure if this functionality exists already, and I'm just missing the obvious, but if not, this would be a fantastic feature to have!

Rotated/Flipped Tiles

There seems to be a problem with rotated/flipped tiles... When you rotate/flip a tile, in Unity it places weird random transparent lines between tiles. I have no idea what causes them other than the fact that it only happens with flipped or rotated tiles. It's a very, very large XML file, so I doubt you'd be able to examine by hand (about 4.5 MB).

image
image

Create specified Tiled layer with quads instead single mesh.

Hi,

I'm happy with Tiled2Unity asset but I found that I need create a few layers with seperated quad mesh only. I thing, this feature is usefull for all and from this point of view, should be nice to have any option or layer properties to generate defined layer with mesh per tile, instead single layer mesh.

AndyGFX

Object layer not to be rendered

Hi Sean,

I'm playing around with Object Layers and the CustomTiledImporterForBlocks-script. I once managed to put tiles on the Object Layer and in Unity instead of tile rendering a had my prefabs spawned over there. I think there was a change in Tiled2Unity that nog renders the tiles form the Object Layer, right?

I hope to get my old behaviour back, or i missed something. What could be the case too ;)

Regards,

Dennis

This is the script i'm using for 'replacing' tiles with prefabs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using UnityEditor;
using UnityEngine;

[Tiled2Unity.CustomTiledImporter]
class CustomTiledImporterForBlocks : Tiled2Unity.ICustomTiledImporter
{

    public void HandleCustomProperties(UnityEngine.GameObject gameObject,
        IDictionary<string, string> props)
    {
        // Does this game object have a spawn property?
        if (!props.ContainsKey("spawn"))
            return;

        // Are we spawning an Appearing Block?
        //if (props["spawn"] != "Coin" && props["spawn"] != "Checkpoint")
            //return;

        // Load the default prefab assest
        // COIN
        string prefabPath = "Assets/Prefabs/Coin.prefab";

        // CHECKPOINTS
        if (props["spawn"] == "Checkpoint") 
        {
            prefabPath = "Assets/Prefabs/Checkpoint.prefab";
        }

        // Instantiate it
        UnityEngine.Object spawn = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject));

        if (spawn != null)
        {
            GameObject spawnInstance = (GameObject)GameObject.Instantiate(spawn);
            spawnInstance.name = spawn.name;

            // Use the position of the game object we're attached to
            spawnInstance.transform.parent = gameObject.transform;
            spawnInstance.transform.localPosition = Vector3.zero;
        }
    }

    public void CustomizePrefab(UnityEngine.GameObject prefab)
    {
        // Do nothing
    }
}


Possibility to import Materials in Resource folder

Hi, sorry to trouble you with more procedurally generation-based issues, but I think I might not be the only one who would like this feature.

The idea is: I'm importing maps with unity:resource = True (as discussed on previous issues) to have them on a Resources folder, where I can instantiate them whenever needed.

This time, however, I would like to change the "tileset" of the map on execution. For this, I created a map with all possible tilesets, so that I guarantee thay they are created by Tiled2Unity as a Material and Texture. Materials are there, but I cannot change them in runtime as they do not exist on a "Resources" folder.

I guess code would be very similar to that change I requested back then with unity:resource. I went and changed method "GetMaterialAssetPath" so that it would always save them on a "Resources" folder. However, best approach would be the same as with Prefabs, so adding an "extraPath" variable to mehtod "GetPrefabAssetPath" would work.

Although I don't think a "property" per map is the way to go this time. If one map uses tileset A with that property, and other does not have the property, but uses the tileset, we would end up with duplicated materials. Maybe a checkbox inside Tiled2Unity.exe?

Thanks again!

Tiled2Unity Imported Object Script Error

Hello I seem to have an error in the Imported Object script.
the error reads
"Assets/Tiled2Unity/Scripts/Editor/ImportTiled2Unity.cs(93,32): error CS0234: The type or namespace name ImportBehaviour' does not exist in the namespaceTiled2Unity'. Are you missing an assembly reference?"
the line in question is line 93

name = Tiled2Unity.ImportBehaviour.GetFilenameWithoutTiled2UnityExtension(name);

I am using Unity 5.3.1 I have a friend using the same version and did not receive the error.
I've tried multiple reinstallations but receive the same problem.

Also nothing gets exported into the prefabs folder when I try to import into unity

Tiled Layers don't get unity:tag's applied to children

If you define a unity:tag to a Layer property it doesn't propagate to child objects.
unity:layer gets applied to all children.

I need this so that tag gets applied to the Collision child.

If this is intended behaviour could you let me know if there is a work around available ?
Thanks!

Stretched objects seem to generate misplaced colliders

I just started messing around with Tiled and Tiled2Unity, was looking into how colliders were generated for Object Layer objects.

From a quick glance, it seems that the collider is misplaced when an object is stretched:

Not stretched object:

2016-07-12 16_59_17-settings

Stretched object:

2016-07-12 16_59_47-start

Properties created via the Object Type Editor do not get exported

If I create a new type with a property in the Object Type Editor and add that type to an object, I can see the property in the properties window of that object. But when I export it, only properties that have been created per object in the Properties window appear in the XML file.

Tiled2Unity doesn't work with Unity 4.x :(

Hey, I'm using Unity 4.3.7f1 (which is needed to compile for Nintendo Wii U) and I'm not able to use Tiled2Unity :(
When using "Import Unity Package to Import" I'll get:
"Assets/Tiled2Unity/Scripts/Runtime/ImportBehaviour.cs(61,34): error CS1061: Type UnityEngine.Transform' does not contain a definition forSetAsFirstSibling' and no extension method SetAsFirstSibling' of typeUnityEngine.Transform' could be found (are you missing a using directive or an assembly reference?)"

When I try to import my map, there's no prefab, texture or any other thing imported :(

Could you check that out and make Tiled2Unity compatible with Unity 4.3.7f1?

Mesh Renderer May have Some Problem.

Unity 5.4
When I import tiled maps into Unity, I find that there are color lines between tiles.
May be change to Sprite Renderer will solve it?

Colission Layer not in Unity

I'm not sure if its my fault or if its a bug. Sorry in advance if its my mistake.
I read up on the Website and it's guides, Googled and watched YouTube videos and i can just not see what i'm doing wrong.

I made a very simple map in Tiled, when Importing it to Tiled2Unity the preview is showing the collision tiles
image

When using the mesh in Unity the collision layer is not showing up.
image
I tried reimport, refresh, restarting unity, complete empty new unity project, new tiled project.

Tiled version: 0.17.0
Tiled2Unity version: 1.0.7.7 on Win10 64bit
Unity3d version: 5.4.0f3 Personal

Link to the tiled file: https://www.dropbox.com/sh/nj98euvt2bcqfqf/AABt30AgHfrSuuHKaZG_vJFca?dl=0

Log output

Opening C:\Users\Philipp\Desktop\collisiondebug.tmx ...
Parsing map root ...
Parsing tileset elements ...
Parse internal tileset 'spaceTest' (gid = 1) ...
Added 1767 tiles
Parse tile data (gid = 641, id 640) ...
Parsing objects in object group ''
Parsing object ...
Parsing layer elements ...
Parse bg layer data ...
Parsing layer data as CSV ...
Parse trees layer data ...
Parsing layer data as CSV ...
Parsing objectgroup elements ...
Map details: { "0" size = 25x25, tile size = 16x16, # tiles = 1767, # layers = 2, # obj groups = 0 }
Parsed: C:\Users\Philipp\Desktop\collisiondebug.tmx 
--------------------------------------------------------------------------------
Loading summary
Succeeded: 1
  Parsed: C:\Users\Philipp\Desktop\collisiondebug.tmx 
Warnings: 0
Errors: 0
--------------------------------------------------------------------------------
Exporting 'C:\Users\Philipp\Desktop\collisiondebug.tmx' to 'C:\Users\Philipp\Dropbox\Projekte\Games\CollisionTest\Assets\Tiled2Unity'
Compiling tiled2unity file: collisiondebug.tiled2unity.xml
Writing 'mesh_0001' mesh group
Writing 'mesh_0002' mesh group
Writing face vertices
Writing face uv coordinates
ImportTexture : will import 'C:\tmp\spaceTest.png' to C:\Users\Philipp\Dropbox\Projekte\Games\CollisionTest\Assets\Tiled2Unity\Textures
Gathering prefab data ...
Clipping '' polygons: 0%
Clipping '' polygons: 100%
Writing as Xml ...
Exporting to: C:\Users\Philipp\Dropbox\Projekte\Games\CollisionTest\Assets\Tiled2Unity\Imported\collisiondebug.tiled2unity.xml
Succesfully exported: C:\Users\Philipp\Dropbox\Projekte\Games\CollisionTest\Assets\Tiled2Unity\Imported\collisiondebug.tiled2unity.xml
  Vertex Scale = 1
  Object Type Xml = <none>
--------------------------------------------------------------------------------
Exporting summary
Succeeded: 1
  Succesfully exported: C:\Users\Philipp\Dropbox\Projekte\Games\CollisionTest\Assets\Tiled2Unity\Imported\collisiondebug.tiled2unity.xml
  Vertex Scale = 1
  Object Type Xml = <none>
Warnings: 0
Errors: 0
--------------------------------------------------------------------------------

Thank you

Export scale not changed

On OSX, when having a certain export scale, and having exported a prefab, then changing the export scale in Tiled2UnityMac, the actual export scale is not updated to the newly set export scale in the GUI.

[Feature request] A way to change the prefab directory

It would be nice if I could specify where to put the final prefabs.
I know you can specify a property to have them put in a Resource folder.
But I'd like to put all my prefabs in a specific place.
Maybe easily accessible string variables would do it.

Exporting 32x32 tiles as a single unit

I'm attempting to export a tiled map made up of 32x32 tiles to a Unity so that I get 1 tile == 1 unit. I'm using a vertex scale of 0.032 and am running into some trouble. The scale of the map appears to "drift" and misalign with Unity's scale.

Here is what my tiled map looks like for reference, this is a 16x16 map made up of 32x32 tiles:
tiledmap

And here is the imported map (some of the mesh renderers on the more colorful layer are turned off):
unityimport

If you look closely, the scale of each tile doesn't appear to be consistent. So while it appears to be mostly aligned in the upper left (note the grid lines):
unityimportupperleft

By the time you get to the upper right, the grid lines no longer match:
unityimportupperright

I am fairly new to Unity and just started using Tiled2Unity the other day so there is a chance that my vertex scale is just off but it seems like based on your article the proper scale for 32x32 should be 0.032.

Any help is welcome.

Tiled2Unity files for use with A* search algorithm

Hi, I've been using Tiled2Unity for my map imports. Things were great, but now I need to start implementing path searches from one part of the map to another (without colliding with any of the colliders), but this seems very difficult with the current map import method as the maps are just saved as textures instead of tiles (or any form of nodes).

Do you have any recommendations on how A* could be implemented on top of the Tile2Unity import file? If this currently seems undoable, it would be great if an update could be made to make this possible.

export error

I did replaced the code of method OnPostprocessModel in Scripts/Editor/TiledAssetPostProcessor.cs at download version of your website, because I could not export...there are the errors:

Assets/Tiled2Unity/Scripts/Editor/TiledAssetPostProcessor.cs(107,65): error CS0234: The type or namespace name ReflectionProbeUsage' does not exist in the namespaceUnityEngine.Rendering'. Are you missing an assembly reference?
Assets/Tiled2Unity/Scripts/Editor/TiledAssetPostProcessor.cs(107,20): error CS1061: Type UnityEngine.MeshRenderer' does not contain a definition forreflectionProbeUsage' and no extension method reflectionProbeUsage' of typeUnityEngine.MeshRenderer' could be found (are you missing a using directive or an assembly reference?)

Objects position incorrect after Tiled2Unity process

I am using Tiled 0.16.1 and Tiled2UnityMac 1.0.7.3 both on Mac. I work with isometric map. On top of the map I add objects, which are tileset type of "Collection of images".

In Tiled2UnityMac the preview shows same incorrect placements of bitmaps in objects layer that will show in Unity too. Attached is a small Tiled project that shows the problem. Observe the position of the house and the train car in Tiled and in Tiled2Unity preview.

Bug report.zip
Here are screenshots that show the problem.
Tiled screenshot (correct)
tiled screenshot
Tiled2Unity preview screenshot (incorrect)
tiled2unitypreviewscreenshot

Animation problem when animating with different amount of frames

Hi!!
There is a bug (I believe) when we have tiles with different amount of frames in the same layer.

For example, I have in my tileset: animation A with 3 frames and animation B with 4 frames..

The importer generates 4 objects.. 3 objects containing meshes for the first 3 frames of A and B, and 1 object containing the last frame of B.

When animation A loops for the 1st frame, animation B is in the 4th frame. At this time both meshes are turned on. Which doesn't make much sense.. It looks right for A, but B is messed up.

I don't really know the best way to solve this. But I'm still happy with the new animation importing system.. We had done lots of optimizations in the last one, but now it looks much more efficient.

Recreate new obj and prefab when load project without library folder ?

I download project from svn ,then my map prefab that use the msh obj with my custom script will lose, then i find the obj will recreate when open the project without library folder.how can i do prevent import script recprocess to create obj and prefab to recover my exit map prefab when open new project ?

Wiki page is missing properties

Would be nice to have the docs for all layer/map properties in one place.

From the looks of it, the full set is:

            knownProperties.Add("unity:layer");
            knownProperties.Add("unity:tag");
            knownProperties.Add("unity:sortingLayerName");
            knownProperties.Add("unity:sortingOrder");
            knownProperties.Add("unity:scale");
            knownProperties.Add("unity:isTrigger");
            knownProperties.Add("unity:ignore");
            knownProperties.Add("unity:resource");

Thanks for the great tool :)

Getting the custom property on a placed tile

Hi Sean,

How do i get the prop from a tile (like setting an objects rotation or health variable)?

I have set the custom property 'tileRotation' on a placed tile but i can't find a way to read it, props["tileRotation"] is not working.

Rotating the tile in the editor doesn't work either, so this was my workaround ;)

Regards,

Dennis

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using UnityEditor;
using UnityEngine;

[Tiled2Unity.CustomTiledImporter]
class CustomTiledImporterForBlocks : Tiled2Unity.ICustomTiledImporter
{

    public void HandleCustomProperties(UnityEngine.GameObject gameObject,
        IDictionary<string, string> props)
    {
        // Does this game object have a spawn property?
        if (!props.ContainsKey("spawn"))
            return;

        // Load the default prefab assest
        // COIN
        string prefabPath = "Assets/Prefabs/Coin.prefab";

        // PLAYERSTART
        // Is just the first checkpoint (the levelmanager can find it by name)
        if (props["spawn"] == "PlayerStart") 
        {
            prefabPath = "Assets/Prefabs/Checkpoint.prefab";
        }

        // CHECKPOINTS
        if (props["spawn"] == "Checkpoint") 
        {
            prefabPath = "Assets/Prefabs/Checkpoint.prefab";
        }

        // ENEMIES
        if (props["spawn"] == "Enemy") 
        {
            prefabPath = "Assets/Prefabs/Enemy.prefab";
        }

        // LASERS
        if (props["spawn"] == "Laser")
        {
            prefabPath = "Assets/Prefabs/Laser.prefab";
        }

        // Instantiate it
        UnityEngine.Object spawn = AssetDatabase.LoadAssetAtPath(prefabPath, typeof(GameObject));

        if (spawn != null)
        {
            GameObject spawnInstance = (GameObject)GameObject.Instantiate(spawn);
            spawnInstance.name = props["spawn"];

            // Use the position of the game object we're attached to
            spawnInstance.transform.parent = gameObject.transform;
            spawnInstance.transform.localPosition = Vector3.zero;
        }

        // Remove old tile object
        Transform oldTileObject = gameObject.transform.Find("TileObject");

        if (oldTileObject != null)
        {
            GameObject.DestroyImmediate(oldTileObject.gameObject);
        }
    }

    public void CustomizePrefab(UnityEngine.GameObject prefab)
    {
        // Do nothing
    }
}

Optional 3D Colliders generation

Hello there.

What do you think about implementing optional generation of 3D colliders? 3D Physics actually performs better than 2D as it is multi-threaded.

I will try to make some research.

Sorry if it is inappropriate place for ideas.

Exporting with convex colliders throws: Error marking neighbors -- t doesn't contain edge p1-p2!

I just came accross this bug when using the "generate convex colliders" option in the exporter tool on Windows 10.

My configurations are as follows:

  • Tiled 0.16.1
  • Tiled2Unity 1.0.7.2

How to reproduce

  • Use this small reproduction map: TiledRepro.zip
  • Setup Tiled2Unity and try to export the map

Export tool messages during export

Command: E:/TiledRepro/Repro.tmx
--------------------------------------------------------------------------------
Arguments summary
Succeeded: 0
Warnings: 0
Errors: 0
--------------------------------------------------------------------------------
Opening E:\TiledRepro\Repro.tmx ...
Parsing map root ...
Parsing tileset elements ...
Parse internal tileset 'Common' (gid = 1) ...
Added 6 tiles
Parse tile data (gid = 1, id 0) ...
Parsing objects in object group ''
Parsing object ...
Parse tile data (gid = 2, id 1) ...
Parsing objects in object group ''
Parsing object ...
Parse tile data (gid = 3, id 2) ...
Parsing objects in object group ''
Parsing object ...
Parsing layer elements ...
Parse Tile Layer 1 layer data ...
Parsing layer data as base64 string ...
Parsing objectgroup elements ...
Map details: { "0" size = 3x3, tile size = 16x16, # tiles = 6, # layers = 1, # obj groups = 0 }
Parsed: E:\TiledRepro\Repro.tmx 
--------------------------------------------------------------------------------
Loading summary
Succeeded: 1
  Parsed: E:\TiledRepro\Repro.tmx 
Warnings: 0
Errors: 0
--------------------------------------------------------------------------------
Exporting 'E:\TiledRepro\Repro.tmx' to 'E:\TiledRepro\Tiled2Unity'
Compiling tiled2unity file: Repro.tiled2unity.xml
Writing 'mesh_0001' mesh group
Writing face vertices
Writing face uv coordinates
ImportTexture : will import 'e:\TiledRepro\Common.png' to E:\TiledRepro\Tiled2Unity\Textures
Gathering prefab data ...
Clipping '' polygons: 0%
Clipping '' polygons: 100%
Error marking neighbors -- t doesn't contain edge p1-p2!
--------------------------------------------------------------------------------
Exporting summary
Succeeded: 0
Warnings: 0
Errors: 1
  Error marking neighbors -- t doesn't contain edge p1-p2!
--------------------------------------------------------------------------------

With Tiled2Unity 1.0.6.0, there's an exception window output as well that might provide more insight:

Exception window (for Tiled2Unity 1.0.6.0)

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Exception: Error marking neighbors -- t doesn't contain edge p1-p2!
   at Poly2Tri.DelaunayTriangle.MarkNeighbor(TriangulationPoint p1, TriangulationPoint p2, DelaunayTriangle t)
   at Poly2Tri.DTSweep.Fill(DTSweepContext tcx, AdvancingFrontNode node)
   at Poly2Tri.DTSweep.PointEvent(DTSweepContext tcx, TriangulationPoint point)
   at Poly2Tri.DTSweep.Sweep(DTSweepContext tcx)
   at Poly2Tri.DTSweep.Triangulate(DTSweepContext tcx)
   at Poly2Tri.P2T.Triangulate(PolygonSet ps)
   at Tiled2Unity.ConvexPolygonSet.GetTriangleListFromClipperSolution(PolyTree solution)
   at Tiled2Unity.LayerClipper.<SolutionPolygons_Simple>d__7.MoveNext()
   at Tiled2Unity.TiledMapExporter.AddPolygonCollider2DElements_Convex(PolyTree solution, List`1 xmlList)
   at Tiled2Unity.TiledMapExporter.CreateCollisionElementForLayer(TmxLayer layer)
   at Tiled2Unity.TiledMapExporter.CreatePrefabElement()
   at Tiled2Unity.TiledMapExporter.Export(String exportToTiled2UnityPath)
   at Tiled2Unity.Tiled2UnityForm.buttonExport_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1080.0 built by: NETFXREL3STAGE
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
Tiled2Unity
    Assembly Version: 1.0.6.0
    Win32 Version: 1.0.6.0
    CodeBase: file:///t:/Tiled2Unity/Tiled2Unity.exe
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1081.0 built by: NETFXREL3STAGE
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1038.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1078.0 built by: NETFXREL3STAGE
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1038.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1038.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1064.2 built by: NETFXREL3STAGE
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Accessibility
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1038.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
System.Xml.Linq
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1038.0 built by: NETFXREL2
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml.Linq/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
----------------------------------------
PresentationCore
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1080.0 built by: NETFXREL3STAGE
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_64/PresentationCore/v4.0_4.0.0.0__31bf3856ad364e35/PresentationCore.dll
----------------------------------------
WindowsBase
    Assembly Version: 4.0.0.0
    Win32 Version: 4.6.1080.0 built by: NETFXREL3STAGE
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/WindowsBase/v4.0_4.0.0.0__31bf3856ad364e35/WindowsBase.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Opacity of Layers

I created an animation layer and set it to 0.75f opacity and tried to exporting it. When I checked in Unity, it was opaque. Is opacity currently supported with Tiled2Unity?

Option to export each polygon collider as a separate collider gameobject.

Hello!

I have this map being exported from Tiled to Unity via this tool: http://i.imgur.com/3AL4UPP.png

When this prefab is loaded, the collider that was generated will be one of two paths under the same game object. What I would like to see is an option to export each of these two to separate polygons. This would help me out when working with something such as PolyNav2D.

Right now I solve this with a script attached to the collider that splits it into child objects, but that's probably not the best way of doing it. Here's the script I use: http://pastebin.com/0Bdv97jB

It splits each path in the polygon and makes a new sub object to the collider gameobject. If this could be done as an option from Tiled2Unity, that'd make it a lot nicer to work with :)

Thanks for a great tool, and keep up the great work!

ImportBehaviour.cs

I guess ImportBehaviour.cs should be in the Editor folder rather than Runtime, because it has UnityEditor namespace and while making Unity build it will say that type or namespace name `UnityEditor' could not be found.

Regression from 1.0.0.0.

[Tiled2UnityLite][OSX] whitespaces in paths in command causes failure

If my file path in %mapfile or the output file path contains a white space, Tiled2UnityLite can't find the file path. Even adding double quotation marks or single plus double quotation marks (eg. '"my/map path"') doesn't work.

When I add "echo $0 $* &> tiled2unitylite.log" in the shell script to check the input, I notice that the double quotation marks have disappeared. Which is strange.

Disabling "Optimize Mesh" doesn't disable all mesh optimizations

The optimization I'm trying to disable is this: if the ordering of the tris/quads in the tilemap matches the ordering of tiles in the source texture, the mesh will share vertices between triangles.

While this reduces the total number of necessary vertices and uv pairs (in my test map, it reduces the number by ~25%), the effect may be nominal for randomized/packed tilesets, and it comes at the cost of making it difficult to programmatically manipulate the mesh.

Is there a way to disable this optimization? To force the loaded mesh to generate the 4 vertices + uv pairs for every quad? I have tried unchecking the "Optimize Mesh" checkbox in the generated mesh import settings, but it doesn't seem to help.

As a workaround, I can postprocess my tileset using a montage or checkerboard effect, but this makes working with the assets in tiled a lot more painful.

Is this something tiled2unity is doing that can potentially be disabled? Or is it something Unity is doing on its own to optimize the meshes?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.