mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-12 05:48:47 -05:00
Merge pull request #1089 from Santarh/publicSuffix
Make public resource fix method
This commit is contained in:
@@ -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<string> used, string originalName)
|
||||
public static string FixNameUnique(HashSet<string> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user