diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs
index 2841754fd..95b90e9bd 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfData.cs
@@ -81,6 +81,14 @@ namespace UniGLTF
_storage = storage;
MigrationFlags = migrationFlags;
+ // Version Compatibility
+ RestoreOlderVersionValues(json, GLTF);
+
+ foreach (var image in GLTF.images)
+ {
+ image.uri = PrepareImageUri(image.uri);
+ }
+
// init
if (Chunks != null)
{
@@ -97,6 +105,47 @@ namespace UniGLTF
_UriCache.Clear();
}
+ private static void RestoreOlderVersionValues(string Json, glTF GLTF)
+ {
+ var parsed = UniJSON.JsonParser.Parse(Json);
+ for (int i = 0; i < GLTF.images.Count; ++i)
+ {
+ if (string.IsNullOrEmpty(GLTF.images[i].name))
+ {
+ try
+ {
+ var extraName = parsed["images"][i]["extra"]["name"].Value.GetString();
+ if (!string.IsNullOrEmpty(extraName))
+ {
+ GLTF.images[i].name = extraName;
+ }
+ }
+ catch (Exception)
+ {
+ // do nothing
+ }
+ }
+ }
+ }
+
+ static string PrepareImageUri(string uri)
+ {
+ if (string.IsNullOrEmpty(uri))
+ {
+ return uri;
+ }
+
+ if (uri.StartsWith("./"))
+ {
+ // skip
+ uri = uri.Substring(2);
+ }
+
+ // %20 to ' ' etc...
+ var unescape = Uri.UnescapeDataString(uri);
+ return unescape;
+ }
+
public static GltfData CreateFromExportForTest(ExportingGltfData data)
{
return CreateFromGltfDataForTest(data.Gltf, data.BinBytes);
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfDuplicatedNameConversionRule.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfDuplicatedNameConversionRule.cs
new file mode 100644
index 000000000..ea1bfa18c
--- /dev/null
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfDuplicatedNameConversionRule.cs
@@ -0,0 +1,265 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+
+namespace UniGLTF
+{
+ ///
+ /// `v0.129.0`
+ /// glTF は仕様として、node 等の名前の重複を許している。
+ /// しかし Unity にロードする上では、名前が重複すると困る場面が多い。
+ /// したがって UniVRM ではロード時に、名前を重複しないように破壊的変更を行う仕様とする。
+ /// ここではその命名変更規則を定義する。
+ ///
+ public static class GltfDuplicatedNameConversionRule
+ {
+ public static readonly string UniqueFixResourceSuffix = "__UNIGLTF__DUPLICATED__";
+ private static readonly Regex _removeUniqueFixResourceSuffix = new Regex($@"^(.+){UniqueFixResourceSuffix}(\d+)$");
+
+ public static string FixNameUnique(HashSet used, string originalName)
+ {
+ if (used.Add(originalName))
+ {
+ return originalName;
+ }
+
+ var duplicatedIdx = 2;
+ while (true)
+ {
+ var newName = $"{originalName}{UniqueFixResourceSuffix}{duplicatedIdx++}";
+ if (used.Add(newName))
+ {
+ return newName;
+ }
+ }
+ }
+
+ ///
+ /// GlbLowLevelParser.FixNameUnique で付与した Suffix を remove
+ ///
+ public static void FixName(glTF gltf)
+ {
+ var regex = new Regex($@"{UniqueFixResourceSuffix}\d+$");
+ foreach (var gltfImages in gltf.images)
+ {
+ if (regex.IsMatch(gltfImages.name))
+ {
+ gltfImages.name = regex.Replace(gltfImages.name, string.Empty);
+ }
+ }
+ foreach (var gltfMaterial in gltf.materials)
+ {
+ if (regex.IsMatch(gltfMaterial.name))
+ {
+ gltfMaterial.name = regex.Replace(gltfMaterial.name, string.Empty);
+ }
+ }
+ foreach (var gltfAnimation in gltf.animations)
+ {
+ if (regex.IsMatch(gltfAnimation.name))
+ {
+ gltfAnimation.name = regex.Replace(gltfAnimation.name, string.Empty);
+ }
+ }
+ }
+
+ public static bool TryGetOriginalName(string name, out string originalName)
+ {
+ var match = _removeUniqueFixResourceSuffix.Match(name);
+ if (match.Success)
+ {
+ originalName = match.Groups[1].Value;
+ return true;
+ }
+ else
+ {
+ originalName = name;
+ return false;
+ }
+ }
+
+ public static void FixMeshNameUnique(glTF GLTF)
+ {
+ var used = new HashSet();
+ foreach (var mesh in GLTF.meshes)
+ {
+ if (string.IsNullOrEmpty(mesh.name))
+ {
+ // empty
+ mesh.name = "mesh_" + Guid.NewGuid().ToString("N");
+ used.Add(mesh.name);
+ }
+ else
+ {
+ var lower = mesh.name.ToLower();
+ if (used.Contains(lower))
+ {
+ // rename
+ var uname = lower + "_" + Guid.NewGuid().ToString("N");
+ mesh.name = uname;
+ lower = uname;
+ }
+ used.Add(lower);
+ }
+ }
+ }
+
+ public static void RenameImageFromTexture(glTF GLTF, int i)
+ {
+ foreach (var texture in GLTF.textures)
+ {
+ if (texture.source == i)
+ {
+ if (!string.IsNullOrEmpty(texture.name))
+ {
+ GLTF.images[i].name = texture.name;
+ return;
+ }
+ }
+ }
+ }
+
+ ///
+ /// gltfTexture.name を Unity Asset 名として運用する。
+ /// ユニークである必要がある。
+ ///
+ public static void FixTextureNameUnique(glTF GLTF)
+ {
+ // NOTE: Windows FileSystem は大文字小文字の違いは同名ファイルとして扱ってしまうため, IgnoreCase で評価する.
+ var used = new HashSet(StringComparer.OrdinalIgnoreCase);
+ for (var textureIdx = 0; textureIdx < GLTF.textures.Count; ++textureIdx)
+ {
+ var gltfTexture = GLTF.textures[textureIdx];
+ if (gltfTexture.source.HasValidIndex())
+ {
+ var gltfImage = GLTF.images[gltfTexture.source.Value];
+ if (!string.IsNullOrEmpty(gltfImage.uri) && !gltfImage.uri.StartsWith("data:"))
+ {
+ // from image uri
+ gltfTexture.name = Path.GetFileNameWithoutExtension(gltfImage.uri);
+ }
+ if (string.IsNullOrEmpty(gltfTexture.name))
+ {
+ // use image name
+ gltfTexture.name = gltfImage.name;
+ }
+ }
+ if (string.IsNullOrEmpty(gltfTexture.name))
+ {
+ gltfTexture.name = $"texture_{textureIdx}";
+ }
+
+ gltfTexture.name = FixNameUnique(used, gltfTexture.name);
+ }
+ }
+
+ public static void FixMaterialNameUnique(glTF GLTF)
+ {
+ // NOTE: Windows FileSystem は大文字小文字の違いは同名ファイルとして扱ってしまうため, IgnoreCase で評価する.
+ var used = new HashSet(StringComparer.OrdinalIgnoreCase);
+ for (var materialIdx = 0; materialIdx < GLTF.materials.Count; ++materialIdx)
+ {
+ var material = GLTF.materials[materialIdx];
+
+ if (string.IsNullOrEmpty(material.name))
+ {
+ material.name = $"material_{materialIdx}";
+ }
+
+ material.name = FixNameUnique(used, material.name);
+ }
+ }
+
+ ///
+ /// rename empty name to $"{index}"
+ ///
+ public static void FixNodeName(glTF GLTF)
+ {
+ for (var i = 0; i < GLTF.nodes.Count; ++i)
+ {
+ var node = GLTF.nodes[i];
+ if (string.IsNullOrWhiteSpace(node.name))
+ {
+ node.name = $"{i}";
+ }
+ }
+ }
+
+ public static void FixAnimationNameUnique(glTF GLTF)
+ {
+ // NOTE: Windows FileSystem は大文字小文字の違いは同名ファイルとして扱ってしまうため, IgnoreCase で評価する.
+ var used = new HashSet(StringComparer.OrdinalIgnoreCase);
+ for (int i = 0; i < GLTF.animations.Count; ++i)
+ {
+ var animation = GLTF.animations[i];
+
+ if (string.IsNullOrEmpty(animation.name))
+ {
+ animation.name = $"animation_{i}";
+ }
+
+ animation.name = FixNameUnique(used, animation.name);
+ }
+ }
+
+ public static void FixNodeNameUnique(glTF GLTF)
+ {
+ var m_uniqueNameSet = new HashSet();
+ int counter = 1;
+ for (var i = 0; i < GLTF.nodes.Count; ++i)
+ {
+ RenameIfDupName(GLTF.nodes, i, m_uniqueNameSet, ref counter);
+ }
+ }
+
+ static void RenameIfDupName(List nodes, int index, HashSet m_uniqueNameSet, ref int m_counter)
+ {
+ var t = nodes[index];
+
+ if (!m_uniqueNameSet.Contains(t.name))
+ {
+ m_uniqueNameSet.Add(t.name);
+ return;
+ }
+
+ var parent = nodes.FirstOrDefault(x => x.children != null && x.children.Contains(index));
+ if (parent != null && (t.children == null || t.children.Length == 0))
+ {
+ /// AvatarBuilder:BuildHumanAvatar で同名の Transform があるとエラーになる。
+ ///
+ /// AvatarBuilder 'GLTF': Ambiguous Transform '32/root/torso_1/torso_2/torso_3/torso_4/torso_5/torso_6/torso_7/neck_1/neck_2/head/ENDSITE' and '32/root/torso_1/torso_2/torso_3/torso_4/torso_5/torso_6/torso_7/l_shoulder/l_up_arm/l_low_arm/l_hand/ENDSITE' found in hierarchy for human bone 'Head'. Transform name mapped to a human bone must be unique.
+ /// UnityEngine.AvatarBuilder:BuildHumanAvatar (UnityEngine.GameObject,UnityEngine.HumanDescription)
+ /// UniHumanoid.AvatarDescription:CreateAvatar (UnityEngine.Transform)
+ ///
+ /// 主に BVH の EndSite 由来の GameObject 名が重複することへの対策
+ /// ex: parent-ENDSITE
+ var newName = $"{parent.name}-{t.name}";
+ if (!m_uniqueNameSet.Contains(newName))
+ {
+ UniGLTFLogger.Warning($"force rename !!: {t.name} => {newName}");
+ t.name = newName;
+ m_uniqueNameSet.Add(newName);
+ return;
+ }
+ }
+
+ // 連番
+ for (int i = 0; i < 100; ++i)
+ {
+ // ex: name.1
+ var newName = $"{t.name}{m_counter++}";
+ if (!m_uniqueNameSet.Contains(newName))
+ {
+ UniGLTFLogger.Warning($"force rename: {t.name} => {newName}");
+ t.name = newName;
+ m_uniqueNameSet.Add(newName);
+ return;
+ }
+ }
+
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfDuplicatedNameConversionRule.cs.meta b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfDuplicatedNameConversionRule.cs.meta
new file mode 100644
index 000000000..41b3ab0b0
--- /dev/null
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/GltfDuplicatedNameConversionRule.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8ded08d75fb22a94f80265d4403d5b3e
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs
index cebd8c4a3..b41fa5eed 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/ImporterContext.cs
@@ -14,7 +14,7 @@ namespace UniGLTF
{
public readonly bool IsAssetImport;
private readonly ImporterContextSettings _settings;
-
+
public ITextureDescriptorGenerator TextureDescriptorGenerator { get; protected set; }
public IMaterialDescriptorGenerator MaterialDescriptorGenerator { get; protected set; }
public TextureFactory TextureFactory { get; }
@@ -95,6 +95,9 @@ namespace UniGLTF
MeasureTime = new ImporterContextSpeedLog().MeasureTime;
}
+ // 前処理
+ await PreprocessAsync(awaitCaller);
+
if (GLTF.extensionsRequired != null)
{
var sb = new List();
@@ -142,6 +145,24 @@ namespace UniGLTF
return instance;
}
+ ///
+ /// from `v0.129.0`
+ /// `GltfData` をロードする前に行う必要のある処理を記述する。
+ /// デフォルト実装では、glTF では許されるが Unity では問題となる名前の重複を解決する。
+ ///
+ protected virtual async Task PreprocessAsync(IAwaitCaller awaitCaller)
+ {
+ await awaitCaller.Run(() =>
+ {
+ // `v0.129.0` GlbLowLevelParser.Parse からこちらに移動
+ GltfDuplicatedNameConversionRule.FixMeshNameUnique(GLTF);
+ GltfDuplicatedNameConversionRule.FixTextureNameUnique(GLTF);
+ GltfDuplicatedNameConversionRule.FixMaterialNameUnique(GLTF);
+ GltfDuplicatedNameConversionRule.FixNodeName(GLTF);
+ GltfDuplicatedNameConversionRule.FixAnimationNameUnique(GLTF);
+ });
+ }
+
public virtual async Task LoadAnimationAsync(IAwaitCaller awaitCaller)
{
if (GLTF.animations != null && GLTF.animations.Any())
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs
index c1b8798d9..a8c204fd8 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs
@@ -13,9 +13,6 @@ namespace UniGLTF
///
public sealed class GlbLowLevelParser
{
- public static readonly string UniqueFixResourceSuffix = "__UNIGLTF__DUPLICATED__";
- private static readonly Regex _removeUniqueFixResourceSuffix = new Regex($@"^(.+){UniqueFixResourceSuffix}(\d+)$");
-
private readonly string _path;
private readonly byte[] _binary;
@@ -79,191 +76,9 @@ namespace UniGLTF
throw new UniGLTFException("unknown gltf version {0}", GLTF.asset.version);
}
- // Version Compatibility
- RestoreOlderVersionValues(json, GLTF);
-
- FixMeshNameUnique(GLTF);
- foreach (var image in GLTF.images)
- {
- image.uri = PrepareUri(image.uri);
- }
- FixTextureNameUnique(GLTF);
- FixMaterialNameUnique(GLTF);
- FixNodeName(GLTF);
- FixAnimationNameUnique(GLTF);
-
return new GltfData(path, json, GLTF, chunks, storage, migrationFlags);
}
- private static void FixMeshNameUnique(glTF GLTF)
- {
- var used = new HashSet();
- foreach (var mesh in GLTF.meshes)
- {
- if (string.IsNullOrEmpty(mesh.name))
- {
- // empty
- mesh.name = "mesh_" + Guid.NewGuid().ToString("N");
- used.Add(mesh.name);
- }
- else
- {
- var lower = mesh.name.ToLower();
- if (used.Contains(lower))
- {
- // rename
- var uname = lower + "_" + Guid.NewGuid().ToString("N");
- mesh.name = uname;
- lower = uname;
- }
- used.Add(lower);
- }
- }
- }
-
- private static void RenameImageFromTexture(glTF GLTF, int i)
- {
- foreach (var texture in GLTF.textures)
- {
- if (texture.source == i)
- {
- if (!string.IsNullOrEmpty(texture.name))
- {
- GLTF.images[i].name = texture.name;
- return;
- }
- }
- }
- }
-
- ///
- /// image.uri を前理
- ///
- ///
- ///
- public static string PrepareUri(string uri)
- {
- if (string.IsNullOrEmpty(uri))
- {
- return uri;
- }
-
- if (uri.StartsWith("./"))
- {
- // skip
- uri = uri.Substring(2);
- }
-
- // %20 to ' ' etc...
- var unescape = Uri.UnescapeDataString(uri);
- return unescape;
- }
-
- ///
- /// gltfTexture.name を Unity Asset 名として運用する。
- /// ユニークである必要がある。
- ///
- private static void FixTextureNameUnique(glTF GLTF)
- {
- // NOTE: Windows FileSystem は大文字小文字の違いは同名ファイルとして扱ってしまうため, IgnoreCase で評価する.
- var used = new HashSet(StringComparer.OrdinalIgnoreCase);
- for (var textureIdx = 0; textureIdx < GLTF.textures.Count; ++textureIdx)
- {
- var gltfTexture = GLTF.textures[textureIdx];
- if (gltfTexture.source.HasValidIndex())
- {
- var gltfImage = GLTF.images[gltfTexture.source.Value];
- if (!string.IsNullOrEmpty(gltfImage.uri) && !gltfImage.uri.StartsWith("data:"))
- {
- // from image uri
- gltfTexture.name = Path.GetFileNameWithoutExtension(gltfImage.uri);
- }
- if (string.IsNullOrEmpty(gltfTexture.name))
- {
- // use image name
- gltfTexture.name = gltfImage.name;
- }
- }
- if (string.IsNullOrEmpty(gltfTexture.name))
- {
- gltfTexture.name = $"texture_{textureIdx}";
- }
-
- gltfTexture.name = FixNameUnique(used, gltfTexture.name);
- }
- }
-
- private static void FixMaterialNameUnique(glTF GLTF)
- {
- // NOTE: Windows FileSystem は大文字小文字の違いは同名ファイルとして扱ってしまうため, IgnoreCase で評価する.
- var used = new HashSet(StringComparer.OrdinalIgnoreCase);
- for (var materialIdx = 0; materialIdx < GLTF.materials.Count; ++materialIdx)
- {
- var material = GLTF.materials[materialIdx];
-
- if (string.IsNullOrEmpty(material.name))
- {
- material.name = $"material_{materialIdx}";
- }
-
- material.name = FixNameUnique(used, material.name);
- }
- }
-
- ///
- /// rename empty name to $"{index}"
- ///
- private static void FixNodeName(glTF GLTF)
- {
- for (var i = 0; i < GLTF.nodes.Count; ++i)
- {
- var node = GLTF.nodes[i];
- if (string.IsNullOrWhiteSpace(node.name))
- {
- node.name = $"{i}";
- }
- }
- }
-
- private static void FixAnimationNameUnique(glTF GLTF)
- {
- // NOTE: Windows FileSystem は大文字小文字の違いは同名ファイルとして扱ってしまうため, IgnoreCase で評価する.
- var used = new HashSet(StringComparer.OrdinalIgnoreCase);
- for (int i = 0; i < GLTF.animations.Count; ++i)
- {
- var animation = GLTF.animations[i];
-
- if (string.IsNullOrEmpty(animation.name))
- {
- animation.name = $"animation_{i}";
- }
-
- animation.name = FixNameUnique(used, animation.name);
- }
- }
-
- private static void RestoreOlderVersionValues(string Json, glTF GLTF)
- {
- var parsed = UniJSON.JsonParser.Parse(Json);
- for (int i = 0; i < GLTF.images.Count; ++i)
- {
- if (string.IsNullOrEmpty(GLTF.images[i].name))
- {
- try
- {
- var extraName = parsed["images"][i]["extra"]["name"].Value.GetString();
- if (!string.IsNullOrEmpty(extraName))
- {
- GLTF.images[i].name = extraName;
- }
- }
- catch (Exception)
- {
- // do nothing
- }
- }
- }
- }
public static void AppendImageExtension(glTFImage texture, string extension)
{
@@ -272,38 +87,5 @@ namespace UniGLTF
texture.name = texture.name + extension;
}
}
-
- public static string FixNameUnique(HashSet used, string originalName)
- {
- if (used.Add(originalName))
- {
- return originalName;
- }
-
- var duplicatedIdx = 2;
- while (true)
- {
- var newName = $"{originalName}{UniqueFixResourceSuffix}{duplicatedIdx++}";
- if (used.Add(newName))
- {
- return newName;
- }
- }
- }
-
- public static bool TryGetOriginalName(string name, out string originalName)
- {
- var match = _removeUniqueFixResourceSuffix.Match(name);
- if (match.Success)
- {
- originalName = match.Groups[1].Value;
- return true;
- }
- else
- {
- originalName = name;
- return false;
- }
- }
}
}
\ No newline at end of file
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs
index e2d09bb06..8c0ecbb18 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs
@@ -366,36 +366,7 @@ namespace UniGLTF
GltfTextureExporter.PushGltfTexture(_data, unityTexture, colorSpace, m_textureSerializer);
}
- FixName(_gltf);
- }
-
- ///
- /// GlbLowLevelParser.FixNameUnique で付与した Suffix を remove
- ///
- public static void FixName(glTF gltf)
- {
- var regex = new Regex($@"{GlbLowLevelParser.UniqueFixResourceSuffix}\d+$");
- foreach (var gltfImages in gltf.images)
- {
- if (regex.IsMatch(gltfImages.name))
- {
- gltfImages.name = regex.Replace(gltfImages.name, string.Empty);
- }
- }
- foreach (var gltfMaterial in gltf.materials)
- {
- if (regex.IsMatch(gltfMaterial.name))
- {
- gltfMaterial.name = regex.Replace(gltfMaterial.name, string.Empty);
- }
- }
- foreach (var gltfAnimation in gltf.animations)
- {
- if (regex.IsMatch(gltfAnimation.name))
- {
- gltfAnimation.name = regex.Replace(gltfAnimation.name, string.Empty);
- }
- }
+ GltfDuplicatedNameConversionRule.FixName(_gltf);
}
#endregion
}
diff --git a/Assets/VRM/Runtime/IO/VRMImporterContext.cs b/Assets/VRM/Runtime/IO/VRMImporterContext.cs
index 98dc2bf7a..a674623f5 100644
--- a/Assets/VRM/Runtime/IO/VRMImporterContext.cs
+++ b/Assets/VRM/Runtime/IO/VRMImporterContext.cs
@@ -36,6 +36,15 @@ namespace VRM
_springBoneRuntime = springboneRuntime ?? new Vrm0XSpringBoneDefaultRuntime();
}
+ protected override async Task PreprocessAsync(IAwaitCaller awaitCaller)
+ {
+ await base.PreprocessAsync(awaitCaller);
+ await awaitCaller.Run(() =>
+ {
+ GltfDuplicatedNameConversionRule.FixNodeNameUnique(GLTF);
+ });
+ }
+
#region OnLoad
protected override async Task OnLoadHierarchy(IAwaitCaller awaitCaller, Func MeasureTime)
{
diff --git a/Assets/VRM10/Runtime/IO/Texture/Vrm10TextureDescriptorGenerator.cs b/Assets/VRM10/Runtime/IO/Texture/Vrm10TextureDescriptorGenerator.cs
index ed7ea65c0..df56bcfa3 100644
--- a/Assets/VRM10/Runtime/IO/Texture/Vrm10TextureDescriptorGenerator.cs
+++ b/Assets/VRM10/Runtime/IO/Texture/Vrm10TextureDescriptorGenerator.cs
@@ -95,7 +95,7 @@ namespace UniVRM10
// data.GLTF.textures は前処理によりユニーク性がある
// unique な名前を振り出す
var used = new HashSet(data.GLTF.textures.Select(x => x.name));
- var uniqueName = GlbLowLevelParser.FixNameUnique(used, UniqueThumbnailName);
+ var uniqueName = GltfDuplicatedNameConversionRule.FixNameUnique(used, UniqueThumbnailName);
value = GltfTextureImporter.CreateSrgbFromOnlyImage(data, imageIndex, uniqueName, gltfImage.uri);
return true;
diff --git a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
index db12de492..d7f400d28 100644
--- a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
+++ b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
@@ -235,10 +235,9 @@ namespace UniVRM10
}
// Fix Duplicated name
- gltfExporter.FixName(Storage.Gltf);
+ GltfDuplicatedNameConversionRule.FixName(Storage.Gltf);
}
-
///
/// VRMコンポーネントのエクスポート
///
diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs
index 3c28d48e2..4d5c239bd 100644
--- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs
+++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs
@@ -79,6 +79,15 @@ namespace UniVRM10
m_springboneRuntime = springboneRuntime;
}
+ protected override async Task PreprocessAsync(IAwaitCaller awaitCaller)
+ {
+ await base.PreprocessAsync(awaitCaller);
+ await awaitCaller.Run(() =>
+ {
+ GltfDuplicatedNameConversionRule.FixNodeNameUnique(GLTF);
+ });
+ }
+
static void AssignHumanoid(List nodes, UniGLTF.Extensions.VRMC_vrm.HumanBone humanBone, VrmLib.HumanoidBones key)
{
if (nodes == null)
diff --git a/Assets/VRM10/Runtime/IO/VrmAnimationImporter.cs b/Assets/VRM10/Runtime/IO/VrmAnimationImporter.cs
index b46c8f2d5..b8b4ac37f 100644
--- a/Assets/VRM10/Runtime/IO/VrmAnimationImporter.cs
+++ b/Assets/VRM10/Runtime/IO/VrmAnimationImporter.cs
@@ -26,6 +26,15 @@ namespace UniVRM10
m_vrma = GetExtension(Data);
}
+ protected override async Task PreprocessAsync(IAwaitCaller awaitCaller)
+ {
+ await base.PreprocessAsync(awaitCaller);
+ await awaitCaller.Run(() =>
+ {
+ GltfDuplicatedNameConversionRule.FixNodeNameUnique(GLTF);
+ });
+ }
+
private static VRMC_vrm_animation GetExtension(GltfData data)
{
if (data.GLTF.extensions is UniGLTF.glTFExtensionImport extensions)