Skip to content

Commit

Permalink
fixed a hidden problem where the tileset importer would not report th…
Browse files Browse the repository at this point in the history
…at the source texture was not
  • Loading branch information
Cammin committed Jan 28, 2024
1 parent 8d285f2 commit 17d1c55
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions Assets/LDtkUnity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# 4.2.3
###### January 16, 2024
- Notified of a new error log if a tileset texture's texture is not a TextureType of Sprite.
- Fixed a problem where the export app would not work on Macs
- This issues is not retroactively fixed, so for any Mac users currently facing this issue, add a "$1" to the end of the file's contents in `Library/LDtkTilesetExporter/ExportTilesetDefinitionMax.sh`)

Expand Down
23 changes: 17 additions & 6 deletions Assets/LDtkUnity/Editor/ScriptedImporter/LDtkTilesetImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,15 @@ protected override void Import()
Profiler.EndSample();

Texture2D outputTexture = output.texture;
if (output.sprites.IsNullOrEmpty() && outputTexture == null)
if (outputTexture == null)
{
Logger.LogError("No Sprites or Texture are generated. Possibly because all assets in file are hidden or failed to generate texture.");
Logger.LogError("No Texture was generated. Possibly because it failed to generate texture.");
FailImport();
return;
}
if (output.sprites.IsNullOrEmpty())
{
Logger.LogError("No Sprites are generated. ");
FailImport();
return;
}
Expand Down Expand Up @@ -207,7 +213,7 @@ private LDtkArtifactAssetsTileset MakeAndCacheArtifacts(TextureGenerationOutput

var customData = _definition.Def.CustomDataToDictionary();
var enumTags = _definition.Def.EnumTagsToDictionary();

for (int i = 0; i < output.sprites.Length; i++)
{
Profiler.BeginSample("AddTile");
Expand Down Expand Up @@ -330,8 +336,6 @@ string MakeAssetName()

Debug.Assert(_additionalTiles.Count == additionalRects.Count);
}



private bool PrepareGenerate(TextureImporterPlatformSettings platformSettings, out TextureGenerationOutput output)
{
Expand All @@ -349,6 +353,13 @@ private bool PrepareGenerate(TextureImporterPlatformSettings platformSettings, o
{
_srcTextureImporter.ReadTextureSettings(importerSettings);
}

if (importerSettings.textureType != TextureImporterType.Sprite)
{
output = default;
Logger.LogError($"Didn't generate the texture and sprites for \"{AssetName}\" because the source texture's TextureType is not \"Sprite\".");
return false;
}

platformSettings.format = TextureImporterFormat.RGBA32;
importerSettings.spritePixelsPerUnit = _pixelsPerUnit;
Expand Down Expand Up @@ -387,7 +398,7 @@ private bool PrepareGenerate(TextureImporterPlatformSettings platformSettings, o
Profiler.BeginSample("GetRawTextureData");
NativeArray<Color32> rawData = copy.GetRawTextureData<Color32>();
Profiler.EndSample();

Profiler.BeginSample("TextureGeneration.Generate");
output = TextureGeneration.Generate(
ImportContext, rawData, copy.width, copy.height, _sprites.Concat(_additionalTiles).ToArray(),
Expand Down

0 comments on commit 17d1c55

Please sign in to comment.