diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs index 28591e952..b518b9b9a 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/Parser/GlbLowLevelParser.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Text; +using System.Text.RegularExpressions; using UniJSON; namespace UniGLTF @@ -13,6 +14,8 @@ 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; @@ -274,7 +277,7 @@ namespace UniGLTF } } - private static string FixNameUnique(HashSet used, string originalName) + public static string FixNameUnique(HashSet used, string originalName) { if (used.Add(originalName)) { @@ -291,5 +294,20 @@ namespace UniGLTF } } } + + 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