41 lines
1.0 KiB
C#
41 lines
1.0 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Runtime.CompilerServices;
|
||
|
||
using UnityEngine;
|
||
|
||
namespace XericLibrary.Runtime.MacroLibrary
|
||
{
|
||
public static partial class MacroMath
|
||
{
|
||
|
||
#region 文本
|
||
|
||
/// <summary>
|
||
/// 获取此处的物体名称,如果带有(clone)后缀,则省略这个后缀
|
||
/// </summary>
|
||
[MethodImpl(MethodImplOptions.NoInlining)]
|
||
public static string GetGameObjectNameWithoutClone(GameObject gameObject)
|
||
{
|
||
return GetGameObjectNameWithoutClone(gameObject.name);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取此处的物体名称,如果带有(clone)后缀,则省略这个后缀
|
||
/// </summary>
|
||
[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
|
||
}
|
||
} |