mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-22 16:18:24 -05:00
4912480957
* [Added] Feature for #67 event name suggestion initial version * [Refactored] Cleaned naming code to its own class * [Fixed] c# range is not supported in 2019.4 LTS * * Simplified logic for suggested name in AtomDrawer * Simplified CleanPropertyName - first if-block was catched by second block * Replaced FilterLastIndexOf with typeof(T).Name --------- Co-authored-by: Thimo de Ram <tdram@esites.local> Co-authored-by: Adam Ramberg <adam@mambojambostudios.com>
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;
|
|
}
|
|
}
|
|
}
|
|
|