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:
parent
5d45300935
commit
55dddf8142
@ -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)]
|
||||||
|
|||||||
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user