mirror of
https://github.com/Siccity/xNode.git
synced 2026-02-11 09:38:45 +08:00
Added a virtual OnRename function to base nodes, triggered when a node gets renamed. (#225)
This commit is contained in:
parent
e98bd85531
commit
b526092341
@ -129,9 +129,14 @@ 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;
|
||||||
|
OnRename();
|
||||||
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
|
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary> Called after this node's name has changed. </summary>
|
||||||
|
public virtual void OnRename() { }
|
||||||
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Class)]
|
[AttributeUsage(AttributeTargets.Class)]
|
||||||
public class CustomNodeEditorAttribute : Attribute,
|
public class CustomNodeEditorAttribute : Attribute,
|
||||||
XNodeEditor.Internal.NodeEditorBase<NodeEditor, NodeEditor.CustomNodeEditorAttribute, XNode.Node>.INodeEditorAttrib {
|
XNodeEditor.Internal.NodeEditorBase<NodeEditor, NodeEditor.CustomNodeEditorAttribute, XNode.Node>.INodeEditorAttrib {
|
||||||
|
|||||||
@ -49,6 +49,7 @@ 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());
|
||||||
|
NodeEditor.GetEditor((XNode.Node)target, NodeEditorWindow.current).OnRename();
|
||||||
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
|
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
|
||||||
Close();
|
Close();
|
||||||
target.TriggerOnValidate();
|
target.TriggerOnValidate();
|
||||||
@ -58,6 +59,7 @@ namespace XNodeEditor {
|
|||||||
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;
|
||||||
|
NodeEditor.GetEditor((XNode.Node)target, NodeEditorWindow.current).OnRename();
|
||||||
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
|
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
|
||||||
Close();
|
Close();
|
||||||
target.TriggerOnValidate();
|
target.TriggerOnValidate();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user