From 17d1c55881290bac85c70a7917765ef5e4570da0 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 27 Jan 2024 22:34:29 -0800 Subject: [PATCH] fixed a hidden problem where the tileset importer would not report that the source texture was not --- Assets/LDtkUnity/CHANGELOG.md | 1 + .../ScriptedImporter/LDtkTilesetImporter.cs | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Assets/LDtkUnity/CHANGELOG.md b/Assets/LDtkUnity/CHANGELOG.md index 24f5fb401..411f734ae 100644 --- a/Assets/LDtkUnity/CHANGELOG.md +++ b/Assets/LDtkUnity/CHANGELOG.md @@ -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`) diff --git a/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkTilesetImporter.cs b/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkTilesetImporter.cs index 01545746c..b1cff891d 100644 --- a/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkTilesetImporter.cs +++ b/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkTilesetImporter.cs @@ -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; } @@ -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"); @@ -330,8 +336,6 @@ string MakeAssetName() Debug.Assert(_additionalTiles.Count == additionalRects.Count); } - - private bool PrepareGenerate(TextureImporterPlatformSettings platformSettings, out TextureGenerationOutput output) { @@ -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; @@ -387,7 +398,7 @@ private bool PrepareGenerate(TextureImporterPlatformSettings platformSettings, o Profiler.BeginSample("GetRawTextureData"); NativeArray rawData = copy.GetRawTextureData(); Profiler.EndSample(); - + Profiler.BeginSample("TextureGeneration.Generate"); output = TextureGeneration.Generate( ImportContext, rawData, copy.width, copy.height, _sprites.Concat(_additionalTiles).ToArray(),