using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; using UnityEngine; namespace XericLibrary.Runtime.MacroLibrary { public static partial class MacroMath { #region 文本 /// /// 获取此处的物体名称,如果带有(clone)后缀,则省略这个后缀 /// [MethodImpl(MethodImplOptions.NoInlining)] public static string GetGameObjectNameWithoutClone(GameObject gameObject) { return GetGameObjectNameWithoutClone(gameObject.name); } /// /// 获取此处的物体名称,如果带有(clone)后缀,则省略这个后缀 /// [MethodImpl(MethodImplOptions.NoInlining)] public static string GetGameObjectNameWithoutClone(string gameObjectName) { const string cloneSuffix = "(Clone)"; if(gameObjectName.EndsWith(cloneSuffix)) { int suffixIndex = gameObjectName.LastIndexOf(cloneSuffix); string nameWithoutClone = gameObjectName.Substring(0, suffixIndex); return nameWithoutClone; } return gameObjectName; } #endregion } }