This repository has been archived on 2025-09-23. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
XericLibrary-OLD/Runtime/MicroLibrary/MacroString.cs

41 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
}
}