1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-21 01:36:03 +08:00

Small editor erformance gain. Removed PrettifyCamelCase.

Use ObjectNames.NicifyVariableName instead
This commit is contained in:
Thor Kramer Brigsted 2017-11-28 09:38:21 +01:00
parent d1d2f9766c
commit 215a3475ea
4 changed files with 4 additions and 9 deletions

View File

@ -26,7 +26,7 @@ namespace XNodeEditor {
public virtual void OnHeaderGUI() { public virtual void OnHeaderGUI() {
GUI.color = Color.white; GUI.color = Color.white;
string title = NodeEditorUtilities.PrettifyCamelCase(target.name); string title = target.name;
GUILayout.Label(title, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); GUILayout.Label(title, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30));
} }

View File

@ -110,7 +110,7 @@ namespace XNodeEditor {
/// <summary> Make a simple port field. </summary> /// <summary> Make a simple port field. </summary>
public static void PortField(GUIContent label, NodePort port, params GUILayoutOption[] options) { public static void PortField(GUIContent label, NodePort port, params GUILayoutOption[] options) {
if (port == null) return; if (port == null) return;
if (label == null) EditorGUILayout.LabelField(port.fieldName.PrettifyCamelCase(), options); if (label == null) EditorGUILayout.LabelField(ObjectNames.NicifyVariableName(port.fieldName), options);
else EditorGUILayout.LabelField(label, options); else EditorGUILayout.LabelField(label, options);
Rect rect = GUILayoutUtility.GetLastRect(); Rect rect = GUILayoutUtility.GetLastRect();
if (port.direction == NodePort.IO.Input) rect.position = rect.position - new Vector2(16, 0); if (port.direction == NodePort.IO.Input) rect.position = rect.position - new Vector2(16, 0);

View File

@ -37,13 +37,6 @@ namespace XNodeEditor {
return false; return false;
} }
/// <summary> Turns camelCaseString into Camel Case String </summary>
public static string PrettifyCamelCase(this string camelCase) {
if (string.IsNullOrEmpty(camelCase)) return "";
string s = System.Text.RegularExpressions.Regex.Replace(camelCase, "([A-Z])", " $1", System.Text.RegularExpressions.RegexOptions.Compiled).Trim();
return char.ToUpper(s[0]) + s.Substring(1);
}
/// <summary> Returns true if this can be casted to <see cref="Type"/></summary> /// <summary> Returns true if this can be casted to <see cref="Type"/></summary>
public static bool IsCastableTo(this Type from, Type to) { public static bool IsCastableTo(this Type from, Type to) {
if (to.IsAssignableFrom(from)) return true; if (to.IsAssignableFrom(from)) return true;

View File

@ -23,6 +23,7 @@ namespace XNode {
if (!Application.isPlaying) { if (!Application.isPlaying) {
UnityEditor.AssetDatabase.AddObjectToAsset(node, this); UnityEditor.AssetDatabase.AddObjectToAsset(node, this);
UnityEditor.AssetDatabase.SaveAssets(); UnityEditor.AssetDatabase.SaveAssets();
node.name = UnityEditor.ObjectNames.NicifyVariableName(node.name);
} }
#endif #endif
nodes.Add(node); nodes.Add(node);
@ -38,6 +39,7 @@ namespace XNode {
if (!Application.isPlaying) { if (!Application.isPlaying) {
UnityEditor.AssetDatabase.AddObjectToAsset(node, this); UnityEditor.AssetDatabase.AddObjectToAsset(node, this);
UnityEditor.AssetDatabase.SaveAssets(); UnityEditor.AssetDatabase.SaveAssets();
node.name = UnityEditor.ObjectNames.NicifyVariableName(node.name);
} }
#endif #endif
nodes.Add(node); nodes.Add(node);