Seanba / SuperTiled2Unity

Imports Tiled files to Unity. Better than regular Tiled2Unity.
MIT License
667 stars 84 forks source link

Importing the sample Overhead from super-tiled2unity.v2.1.0 using Unity2022.3.9 will catch the exceptions. #253

Open streamcypher opened 1 year ago

streamcypher commented 1 year ago

SuperTiled2Unity version: unknown, Unity version: 2022.3.9f1

Unknown error encountered. Please report as bug. Stack track is in the console output.

Object reference not set to an instance of an object

Unknown error of type importing 'Assets/ThirdParty/super-tiled2unity/Samples/Overhead/Maps/Zoria Tileset/scraps.tsx': Failed to add object of type SuperTile. Check that the definition is in a file of the same name and that it compiles properly.

Stack Trace:

at (wrapper managed-to-native) UnityEditor.AssetImporters.AssetImportContext.AddObjectToAsset(UnityEditor.AssetImporters.AssetImportContext,string,UnityEngine.Object,UnityEngine.Texture2D)

at UnityEditor.AssetImporters.AssetImportContext.AddObjectToAsset (System.String identifier, UnityEngine.Object obj) [0x00001] in <2e279d988b9d4542841de511fbfdf8c2>:0

at SuperTiled2Unity.Editor.SuperImportContext.AddObjectToAsset (System.String identifier, UnityEngine.Object obj) [0x00001] in D:\Work\UnityWork\hl-client-unity\HerosLand\Assets\ThirdParty\super-tiled2unity\Editor\Importers\SuperImportContext.cs:38

at SuperTiled2Unity.Editor.AtlasBuilder.Commit (System.Single ppu) [0x001bd] in D:\Work\UnityWork\hl-client-unity\HerosLand\Assets\ThirdParty\super-tiled2unity\Editor\AtlasBuilder.cs:246

at SuperTiled2Unity.Editor.AtlasBuilder.Build (System.Single ppu) [0x00029] in D:\Work\UnityWork\hl-client-unity\HerosLand\Assets\ThirdParty\super-tiled2unity\Editor\AtlasBuilder.cs:88

at SuperTiled2Unity.Editor.TilesetLoader.BuildTileset (System.Xml.Linq.XElement xTileset) [0x00054] in D:\Work\UnityWork\hl-client-unity\HerosLand\Assets\ThirdParty\super-tiled2unity\Editor\Loaders\TilesetLoader.cs:101

at SuperTiled2Unity.Editor.TilesetLoader.LoadFromXml (System.Xml.Linq.XElement xTileset) [0x0005c] in D:\Work\UnityWork\hl-client-unity\HerosLand\Assets\ThirdParty\super-tiled2unity\Editor\Loaders\TilesetLoader.cs:41

at SuperTiled2Unity.Editor.TsxAssetImporter.CreateTileset (System.Xml.Linq.XElement xTileset) [0x0008a] in D:\Work\UnityWork\hl-client-unity\HerosLand\Assets\ThirdParty\super-tiled2unity\Editor\Importers\TsxAssetImporter.cs:62

at SuperTiled2Unity.Editor.TsxAssetImporter.ProcessTileset (System.Xml.Linq.XElement xTileset) [0x00001] in D:\Work\UnityWork\hl-client-unity\HerosLand\Assets\ThirdParty\super-tiled2unity\Editor\Importers\TsxAssetImporter.cs:45

at SuperTiled2Unity.Editor.TsxAssetImporter.ImportTsxFile () [0x0001e] in D:\Work\UnityWork\hl-client-unity\HerosLand\Assets\ThirdParty\super-tiled2unity\Editor\Importers\TsxAssetImporter.cs:40

at SuperTiled2Unity.Editor.TsxAssetImporter.InternalOnImportAsset () [0x00018] in D:\Work\UnityWork\hl-client-unity\HerosLand\Assets\ThirdParty\super-tiled2unity\Editor\Importers\TsxAssetImporter.cs:33

at SuperTiled2Unity.Editor.SuperImporter.OnImportAsset (UnityEditor.AssetImporters.AssetImportContext ctx) [0x00065] in D:\Work\UnityWork\hl-client-unity\HerosLand\Assets\ThirdParty\super-tiled2unity\Editor\Importers\SuperImporter.cs:71

UnityEngine.Debug:LogErrorFormat (string,object[])

Seanba commented 1 year ago

Hi there, @streamcypher. It looks like you put Super Tiled2Unity in your Assets folder. I think that should still work but since version 2.0 ST2U is now a proper Unity Package. In other words, you unzip the package into your Packages folder. From there the Unity Package Manager adds it to your project as an Embedded Package.

Seanba commented 1 year ago

Quick question: How do you even import the samples into your project if you've added the ST2U package to your Assets directory?

streamcypher commented 1 year ago

Quick question: How do you even import the samples into your project if you've added the ST2U package to your Assets directory?

I have tried two ways including putting it to assets foldder and importing from Unity Package Manager. The result and errors is same.

streamcypher commented 1 year ago

Quick question: How do you even import the samples into your project if you've added the ST2U package to your Assets directory? I just tried the new version 2.1.1, this problem is resolved. Thanks a lot!

streamcypher commented 1 year ago

Hi there, @streamcypher. It looks like you put Super Tiled2Unity in your Assets folder. I think that should still work but since version 2.0 ST2U is now a proper Unity Package. In other words, you unzip the package into your Packages folder. From there the Unity Package Manager adds it to your project as an Embedded Package.

This problem arise again when importing the sample from the super-tiled2unity.v2.1.1 package with Unity Package Manager.

streamcypher commented 1 year ago

I closed uinty and copy the super-tiled2unity.v2.1.1 folder into package folder in the project, then open unity and importing the sample with package manager, that will not arise the problem.

Foxeh89 commented 1 year ago

I closed uinty and copy the super-tiled2unity.v2.1.1 folder into package folder in the project, then open unity and importing the sample with package manager, that will not arise the problem.

thank you, this worked for me.

Haelle commented 10 months ago

I have the same issue, I'm on Unity2022.3.11 on Linux and using Tiled v2.1.1.

EDIT : this is a Linux problem, the zip is unusable on Linux the files are all in the root directory and have \ in their names where they should be in folders 😫

~The process never ends when importing via the package manager. And Unity freeze when copying the directory in the Packages/ folder (or in Assets/)~

~Any idea ? Linux problem ?~

Haelle commented 10 months ago

I solved the problem with this script to rename all files (and it works on Linux) :

#!/bin/bash

DIR="/path/to/SuperTiled2Unity"
find "$DIR" -type f | while read -r file; do
    newpath=$(echo "$file" | tr '\\' '/')
    mkdir -p "$(dirname "$newpath")"
    mv "$file" "$newpath"
done
751500365 commented 6 months ago

我关闭了uinty并将super-tiled2unity.v2.1.1文件夹复制到项目的包文件夹中,然后打开unity并使用包管理器导入示例,这不会出现问题。

谢谢,这对我有用。

你确定这样能解决吗。我把包分别放到Asset 目录下和Asset 目录外 通过Package manager form disk 导入 都会出现 Failed to add object of type SuperTile. Check that the definition is in a file of the same name and that it compiles properly