diff --git a/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkTilesetImporter.cs b/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkTilesetImporter.cs index c9995fb7e..2f9b1d9c0 100644 --- a/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkTilesetImporter.cs +++ b/Assets/LDtkUnity/Editor/ScriptedImporter/LDtkTilesetImporter.cs @@ -151,7 +151,12 @@ protected override void Import() Profiler.EndSample(); Profiler.BeginSample("PrepareGenerate"); - TextureGenerationOutput output = PrepareGenerate(platformSettings); + if (!PrepareGenerate(platformSettings, out TextureGenerationOutput output)) + { + FailImport(); + Profiler.EndSample(); + return; + } Profiler.EndSample(); Texture2D outputTexture = output.texture; @@ -365,10 +370,8 @@ private static void TilemapColliderTileUpdate() }; } - private TextureGenerationOutput PrepareGenerate(TextureImporterPlatformSettings platformSettings) + private bool PrepareGenerate(TextureImporterPlatformSettings platformSettings, out TextureGenerationOutput output) { - - Debug.Assert(_pixelsPerUnit > 0, $"_pixelsPerUnit was {_pixelsPerUnit}"); TextureImporterSettings importerSettings = new TextureImporterSettings(); @@ -396,8 +399,9 @@ private TextureGenerationOutput PrepareGenerate(TextureImporterPlatformSettings Sprite sprite = AssetDatabase.LoadAssetAtPath(PathToTexture(assetPath)); if (sprite == null) { - FailImport(); - + output = default; + Logger.LogError($"Failed to load the aseprite sprite for \"{AssetName}\". Either the Aseprite file failed to import, or the aseprite file's import settings are configured to not generate a sprite."); + return false; } Profiler.BeginSample("GenerateAsepriteTexture"); @@ -422,15 +426,15 @@ private TextureGenerationOutput PrepareGenerate(TextureImporterPlatformSettings Profiler.EndSample(); Profiler.BeginSample("TextureGeneration.Generate"); - TextureGenerationOutput output = TextureGeneration.Generate( + output = TextureGeneration.Generate( ImportContext, rawData, copy.width, copy.height, _sprites.Concat(_additionalTiles).ToArray(), platformSettings, importerSettings, string.Empty, _secondaryTextures); Profiler.EndSample(); - - return output; + + return true; } - public Texture2D GenerateTextureFromAseprite(Sprite sprite) + private Texture2D GenerateTextureFromAseprite(Sprite sprite) { Texture2D croppedTexture = new Texture2D(_json.PxWid, _json.PxHei, TextureFormat.RGBA32, false, false); diff --git a/Assets/LDtkUnity/Samples~/Samples/atlas/NuclearBlaze_by_deepnight.aseprite.meta b/Assets/LDtkUnity/Samples~/Samples/atlas/NuclearBlaze_by_deepnight.aseprite.meta index bf8051b73..bf7355312 100644 --- a/Assets/LDtkUnity/Samples~/Samples/atlas/NuclearBlaze_by_deepnight.aseprite.meta +++ b/Assets/LDtkUnity/Samples~/Samples/atlas/NuclearBlaze_by_deepnight.aseprite.meta @@ -95,7 +95,7 @@ ScriptedImporter: addSortingGroup: 1 addShadowCasters: 0 importFileNodeState: 1 - platformSettingsDirtyTick: 638318840637542447 + platformSettingsDirtyTick: 638318975741156812 textureAssetName: singleSpriteImportData: - name: