From 940397c6733aecd522bc44dd54fa4f8a5c8c62f7 Mon Sep 17 00:00:00 2001 From: ww-rm Date: Sat, 27 Sep 2025 18:49:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0Texture=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=B6=E7=9A=84=E6=97=A5=E5=BF=97=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Spine/SpineWrappers/TextureLoader.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Spine/SpineWrappers/TextureLoader.cs b/Spine/SpineWrappers/TextureLoader.cs index 0e25705..0d6b0dc 100644 --- a/Spine/SpineWrappers/TextureLoader.cs +++ b/Spine/SpineWrappers/TextureLoader.cs @@ -1,4 +1,5 @@ -using SFML.Graphics; +using NLog; +using SFML.Graphics; using SkiaSharp; using System; using System.Collections.Generic; @@ -22,6 +23,8 @@ namespace Spine.SpineWrappers SpineRuntime41.TextureLoader, SpineRuntime42.TextureLoader { + private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); + /// /// 默认的全局纹理加载器 /// @@ -44,9 +47,18 @@ namespace Spine.SpineWrappers private Texture ReadTexture(string path) { + if (!File.Exists(path)) + { + _logger.Error($"Texture file not found, {path}"); + throw new FileNotFoundException("Texture file not found", path); + } + using var codec = SKCodec.Create(path, out var result); if (codec is null || result != SKCodecResult.Success) + { + _logger.Error($"Failed to create codec '{path}', {result}"); throw new InvalidOperationException($"Failed to create codec '{path}', {result}"); + } var width = codec.Info.Width; var height = codec.Info.Height; @@ -57,7 +69,10 @@ namespace Spine.SpineWrappers result = codec.GetPixels(info, out var pixels); if (result != SKCodecResult.Success) + { + _logger.Error($"Failed to decode image '{path}', {result}"); throw new InvalidOperationException($"Failed to decode image '{path}', {result}"); + } Texture tex = new((uint)width, (uint)height); tex.Update(pixels);