From 7a3e629aed23f0d3246c1e8e364971fbb40496b3 Mon Sep 17 00:00:00 2001 From: matsutaka Date: Wed, 12 Mar 2025 16:42:43 +0900 Subject: [PATCH] =?UTF-8?q?Add:=20UnitySupportedImageTypeDeserializer=20?= =?UTF-8?q?=E3=81=AB=20MarkNonReadable=20=E3=83=97=E3=83=AD=E3=83=91?= =?UTF-8?q?=E3=83=86=E3=82=A3=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UnityEngine.ImageConversion.LoadImage の第二引数 markNonReadable に相当。 --- .../Import/UnitySupportedImageTypeDeserializer.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/Import/UnitySupportedImageTypeDeserializer.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/Import/UnitySupportedImageTypeDeserializer.cs index b81445311..05a71c1df 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/Import/UnitySupportedImageTypeDeserializer.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/Import/UnitySupportedImageTypeDeserializer.cs @@ -9,6 +9,18 @@ namespace UniGLTF /// public sealed class UnitySupportedImageTypeDeserializer : ITextureDeserializer { + /// + /// `true` を指定すると、テクスチャを Non-Readable なものとしてデシリアライズする。 + /// + /// + /// `UnityEngine.ImageConversion.LoadImage` の第二引数 `markNonReadable` に相当。 + /// デフォルト値は `false`。 + /// テクスチャ編集を行わないアプリケーションプログラム等では、 + /// この値を `true` にすることでメモリ使用量の削減を期待できる。 + /// このフラグの効用については `UnityEngine.Texture2D.Apply` に記述がある。 + /// + public bool MarkNonReadable { get; set; } = false; + public async Task LoadTextureAsync(DeserializingTextureInfo textureInfo, IAwaitCaller awaitCaller) { if (textureInfo.ImageData == null) return null; @@ -16,7 +28,7 @@ namespace UniGLTF try { var texture = new Texture2D(2, 2, TextureFormat.ARGB32, textureInfo.UseMipmap, textureInfo.ColorSpace == ColorSpace.Linear); - texture.LoadImage(textureInfo.ImageData); + texture.LoadImage(textureInfo.ImageData, MarkNonReadable); await awaitCaller.NextFrame(); texture.wrapModeU = textureInfo.WrapModeU;