mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 09:16:01 +08:00
Small editor erformance gain. Removed PrettifyCamelCase.
Use ObjectNames.NicifyVariableName instead
This commit is contained in:
parent
d1d2f9766c
commit
215a3475ea
@ -26,7 +26,7 @@ namespace XNodeEditor {
|
||||
|
||||
public virtual void OnHeaderGUI() {
|
||||
GUI.color = Color.white;
|
||||
string title = NodeEditorUtilities.PrettifyCamelCase(target.name);
|
||||
string title = target.name;
|
||||
GUILayout.Label(title, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30));
|
||||
}
|
||||
|
||||
|
||||
@ -110,7 +110,7 @@ namespace XNodeEditor {
|
||||
/// <summary> Make a simple port field. </summary>
|
||||
public static void PortField(GUIContent label, NodePort port, params GUILayoutOption[] options) {
|
||||
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);
|
||||
Rect rect = GUILayoutUtility.GetLastRect();
|
||||
if (port.direction == NodePort.IO.Input) rect.position = rect.position - new Vector2(16, 0);
|
||||
|
||||
@ -37,13 +37,6 @@ namespace XNodeEditor {
|
||||
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>
|
||||
public static bool IsCastableTo(this Type from, Type to) {
|
||||
if (to.IsAssignableFrom(from)) return true;
|
||||
|
||||
@ -23,6 +23,7 @@ namespace XNode {
|
||||
if (!Application.isPlaying) {
|
||||
UnityEditor.AssetDatabase.AddObjectToAsset(node, this);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
node.name = UnityEditor.ObjectNames.NicifyVariableName(node.name);
|
||||
}
|
||||
#endif
|
||||
nodes.Add(node);
|
||||
@ -38,6 +39,7 @@ namespace XNode {
|
||||
if (!Application.isPlaying) {
|
||||
UnityEditor.AssetDatabase.AddObjectToAsset(node, this);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
node.name = UnityEditor.ObjectNames.NicifyVariableName(node.name);
|
||||
}
|
||||
#endif
|
||||
nodes.Add(node);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user