diff --git a/Runtime/MicroLibrary/MacroString.cs b/Runtime/MicroLibrary/MacroString.cs
index 1eb52a2..5836fe4 100644
--- a/Runtime/MicroLibrary/MacroString.cs
+++ b/Runtime/MicroLibrary/MacroString.cs
@@ -1,3 +1,5 @@
+using Sirenix.Utilities.Editor;
+
using System;
using System.Collections;
using System.Collections.Generic;
@@ -12,29 +14,39 @@ namespace XericLibrary.Runtime.MacroLibrary
{
#region 名称文本
- ///
- /// 获取此处的物体名称,如果带有(clone)后缀,则省略这个后缀
- ///
- [MethodImpl(MethodImplOptions.NoInlining)]
- public static string GetGameObjectNameWithoutClone(GameObject gameObject)
- {
- return GetGameObjectNameWithoutClone(gameObject.name);
- }
+ private readonly static string[] ignoresuffix= new string[]{
+ "(Clone)",
+ "(Instance)"
+ };
///
/// 获取此处的物体名称,如果带有(clone)后缀,则省略这个后缀
///
[MethodImpl(MethodImplOptions.NoInlining)]
- public static string GetGameObjectNameWithoutClone(string gameObjectName)
+ [Obsolete("只忽略克隆后缀是过时的")]
+ public static string GetGameObjectNameWithoutClone(GameObject gameObject)
{
- const string cloneSuffix = "(Clone)";
- if(gameObjectName.EndsWith(cloneSuffix))
+ return gameObject.name;
+ }
+
+ ///
+ /// 获取一个对象名称,但忽略括号后缀
+ ///
+ ///
+ ///
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ public static string GetUnityObjectRealName(this UnityEngine.Object obj)
+ {
+ for(int i = 0; i < ignoresuffix.Length; i++)
{
- int suffixIndex = gameObjectName.LastIndexOf(cloneSuffix);
- string nameWithoutClone = gameObjectName.Substring(0, suffixIndex);
- return nameWithoutClone;
+ if(obj.name.EndsWith(ignoresuffix[i]))
+ {
+ int suffixIndex = obj.name.LastIndexOf(ignoresuffix[i]);
+ string nameWithoutClone = obj.name.Substring(0, suffixIndex);
+ return nameWithoutClone;
+ }
}
- return gameObjectName;
+ return obj.name;
}
#endregion
diff --git a/package.json b/package.json
index 281b6f7..5933e0a 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "com.lrss3.xericlibrary",
"displayName": "Xeric Library",
- "version": "0.2.414",
+ "version": "0.2.415",
"unity": "2021.3",
"description": "\u901a\u7528\u5e93\u63d2\u4ef6\u3002"
}
\ No newline at end of file