1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 17:26:02 +08:00

Rename Revert (#164)

- Not working the same way across all versions of Unity.
This commit is contained in:
Adsitoz 2019-06-26 18:08:22 +10:00 committed by Thor Brigsted
parent 5d45300935
commit 55dddf8142
2 changed files with 5 additions and 5 deletions

View File

@ -88,7 +88,7 @@ namespace XNodeEditor {
public void Rename(string newName) { public void Rename(string newName) {
if (newName == null || newName.Trim() == "") newName = NodeEditorUtilities.NodeDefaultName(target.GetType()); if (newName == null || newName.Trim() == "") newName = NodeEditorUtilities.NodeDefaultName(target.GetType());
target.name = newName; target.name = newName;
AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(target), target.name); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
} }
[AttributeUsage(AttributeTargets.Class)] [AttributeUsage(AttributeTargets.Class)]

View File

@ -49,16 +49,16 @@ namespace XNodeEditor {
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 = NodeEditorUtilities.NodeDefaultName(target.GetType()); target.name = NodeEditorUtilities.NodeDefaultName(target.GetType());
AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(target), target.name); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
Close(); Close();
} }
} }
// Rename asset to input text // Rename asset to input text
else { else {
if (GUILayout.Button("Apply") || (e.isKey && e.keyCode == KeyCode.Return)) { if (GUILayout.Button("Apply") || (e.isKey && e.keyCode == KeyCode.Return)) {
target.name = input; target.name = input;
AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(target), target.name); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
Close(); Close();
} }
} }
} }