From 60174491c4d48a92d19a7285548fb4349a9c0d93 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 14 Apr 2021 20:05:08 +0900 Subject: [PATCH] =?UTF-8?q?TextureImportName=20=E3=81=AE=E4=BD=BF=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84=E3=81=A8=E3=81=93=E3=82=8D?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IO/TextureIO/GltfTextureImporter.cs | 15 -------- .../GLTF/IO/Runtime/TextureImportName.cs | 37 +++---------------- 2 files changed, 5 insertions(+), 47 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs index 36f3ab437..30f39c769 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/GltfTextureImporter.cs @@ -84,21 +84,6 @@ namespace UniGLTF return new TextureImportParam(name, ".png", null, offset, scale, sampler, TextureImportTypes.StandardMap, metallicFactor, roughnessFactor, getMetallicRoughnessAsync, getOcclusionAsync, default, default, default, default); } - public static TextureImportName CreateNameExt(glTF gltf, int textureIndex, TextureImportTypes textureType) - { - if (textureIndex < 0 || textureIndex >= gltf.textures.Count) - { - throw new ArgumentOutOfRangeException(); - } - var gltfTexture = gltf.textures[textureIndex]; - if (gltfTexture.source < 0 || gltfTexture.source >= gltf.images.Count) - { - throw new ArgumentOutOfRangeException(); - } - var gltfImage = gltf.images[gltfTexture.source]; - return new TextureImportName(textureType, gltfTexture.name, gltfImage.GetExt(), gltfImage.uri); - } - public static SamplerParam CreateSampler(glTF gltf, int index) { var gltfTexture = gltf.textures[index]; diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/TextureImportName.cs b/Assets/VRMShaders/GLTF/IO/Runtime/TextureImportName.cs index dc9d592e4..060bf77bf 100644 --- a/Assets/VRMShaders/GLTF/IO/Runtime/TextureImportName.cs +++ b/Assets/VRMShaders/GLTF/IO/Runtime/TextureImportName.cs @@ -1,16 +1,10 @@ -using System.IO; +using System; +using System.IO; namespace VRMShaders { - public struct TextureImportName + public static class TextureImportName { - public readonly string GltfName; - public readonly string ConvertedName; - - public readonly string Ext; - public readonly string Uri; - public readonly string ExtractKey; - public static string GetExtractKey(TextureImportTypes type, string gltfName, string convertedName, string uri) { if (type == TextureImportTypes.StandardMap) @@ -20,7 +14,7 @@ namespace VRMShaders } else { - if (!string.IsNullOrEmpty(uri) && !uri.StartsWith("data:")) + if (!string.IsNullOrEmpty(uri) && !uri.StartsWith("data:", StringComparison.Ordinal)) { // external image return Path.GetFileNameWithoutExtension(uri); @@ -33,30 +27,9 @@ namespace VRMShaders } } - public TextureImportName(TextureImportTypes textureType, string gltfName, string ext, string uri) - { - GltfName = gltfName; - ConvertedName = TextureImportName.Convert(gltfName, textureType); - Ext = ext; - Uri = uri; - ExtractKey = GetExtractKey(textureType, gltfName, ConvertedName, uri); - } - - public string GltfFileName => $"{GltfName}{Ext}"; - - public string ConvertedFileName => $"{ConvertedName}.png"; - public const string NORMAL_SUFFIX = ".normal"; public const string STANDARD_SUFFIX = ".standard"; - public static string Convert(string name, TextureImportTypes textureType) - { - switch (textureType) - { - case TextureImportTypes.StandardMap: return $"{name}{STANDARD_SUFFIX}"; - case TextureImportTypes.NormalMap: return $"{name}{NORMAL_SUFFIX}"; - default: return name; - } - } + public static string RemoveSuffix(string src) { if (src.EndsWith(NORMAL_SUFFIX))