mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-23 00:28:23 -05:00
27 lines
837 B
C#
27 lines
837 B
C#
|
using System.Text.RegularExpressions;
|
||
|
using UnityEditor;
|
||
|
|
||
|
namespace UnityAtoms.Editor
|
||
|
{
|
||
|
public static class AtomNameUtils
|
||
|
{
|
||
|
public static string CleanPropertyName(string propertyName)
|
||
|
{
|
||
|
string cleanedProperty = propertyName;
|
||
|
if (Regex.Match(cleanedProperty, @"[a-zA-Z]").Success)
|
||
|
{
|
||
|
var index = Regex.Match(cleanedProperty, @"[a-zA-Z]").Index;
|
||
|
cleanedProperty = cleanedProperty[index].ToString().ToUpper() + cleanedProperty.Substring(index + 1);
|
||
|
}
|
||
|
return cleanedProperty;
|
||
|
}
|
||
|
|
||
|
public static string CreateUniqueName(string atomName)
|
||
|
{
|
||
|
var results = AssetDatabase.FindAssets(atomName);
|
||
|
return results.Length > 0 ? $"{atomName} ({results.Length})" : atomName;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|