mirror of
https://github.com/Siccity/xNode.git
synced 2026-03-26 22:49:02 +08:00
Use new NodeEditorUtilities.NodeDefaultName()
This commit is contained in:
parent
4fe5995c3d
commit
781128cc6e
@ -86,7 +86,7 @@ namespace XNodeEditor {
|
|||||||
|
|
||||||
/// <summary> Rename the node asset. This will trigger a reimport of the node. </summary>
|
/// <summary> Rename the node asset. This will trigger a reimport of the node. </summary>
|
||||||
public void Rename(string newName) {
|
public void Rename(string newName) {
|
||||||
if (newName == null || newName.Trim() == "") newName = UnityEditor.ObjectNames.NicifyVariableName(target.GetType().Name);
|
if (newName == null || newName.Trim() == "") newName = NodeEditorUtilities.NodeDefaultName(target.GetType());
|
||||||
target.name = newName;
|
target.name = newName;
|
||||||
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
|
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,12 +74,7 @@ namespace XNodeEditor {
|
|||||||
public virtual void CreateNode(Type type, Vector2 position) {
|
public virtual void CreateNode(Type type, Vector2 position) {
|
||||||
XNode.Node node = target.AddNode(type);
|
XNode.Node node = target.AddNode(type);
|
||||||
node.position = position;
|
node.position = position;
|
||||||
if (string.IsNullOrEmpty(node.name)) {
|
if (string.IsNullOrEmpty(node.name)) node.name = NodeEditorUtilities.NodeDefaultName(type);
|
||||||
// Automatically remove redundant 'Node' postfix
|
|
||||||
string typeName = type.Name;
|
|
||||||
if (typeName.EndsWith("Node")) typeName = typeName.Substring(0, typeName.LastIndexOf("Node"));
|
|
||||||
node.name = UnityEditor.ObjectNames.NicifyVariableName(typeName);
|
|
||||||
}
|
|
||||||
AssetDatabase.AddObjectToAsset(node, target);
|
AssetDatabase.AddObjectToAsset(node, target);
|
||||||
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
|
||||||
NodeEditorWindow.RepaintAll();
|
NodeEditorWindow.RepaintAll();
|
||||||
|
|||||||
@ -48,7 +48,7 @@ namespace XNodeEditor {
|
|||||||
// If input is empty, revert name to default instead
|
// If input is empty, revert name to default instead
|
||||||
if (input == null || input.Trim() == "") {
|
if (input == null || input.Trim() == "") {
|
||||||
if (GUILayout.Button("Revert to default") || (e.isKey && e.keyCode == KeyCode.Return)) {
|
if (GUILayout.Button("Revert to default") || (e.isKey && e.keyCode == KeyCode.Return)) {
|
||||||
target.name = UnityEditor.ObjectNames.NicifyVariableName(target.GetType().Name);
|
target.name = NodeEditorUtilities.NodeDefaultName(target.GetType());
|
||||||
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
|
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user