Skip to content

Commit

Permalink
added cases to handle Copy and Rename for scenegraphs correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
loomdoom committed Aug 27, 2022
1 parent 37680da commit b23e769
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Scripts/Editor/NodeGraphEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public virtual XNode.Node CopyNode(XNode.Node original) {
XNode.Node node = target.CopyNode(original);
Undo.RegisterCreatedObjectUndo(node, "Duplicate Node");
node.name = original.name;
AssetDatabase.AddObjectToAsset(node, target);
if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(target))) AssetDatabase.AddObjectToAsset(node, target);
if (NodeEditorPreferences.GetSettings().autoSave) AssetDatabase.SaveAssets();
return node;
}
Expand Down
12 changes: 8 additions & 4 deletions Scripts/Editor/RenamePopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ private void OnGUI() {
if (GUILayout.Button("Revert to default") || (e.isKey && e.keyCode == KeyCode.Return)) {
target.name = NodeEditorUtilities.NodeDefaultName(target.GetType());
NodeEditor.GetEditor((XNode.Node)target, NodeEditorWindow.current).OnRename();
AssetDatabase.SetMainObject((target as XNode.Node).graph, AssetDatabase.GetAssetPath(target));
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(target))) {
AssetDatabase.SetMainObject((target as XNode.Node).graph, AssetDatabase.GetAssetPath(target));
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
}
Close();
target.TriggerOnValidate();
}
Expand All @@ -64,8 +66,10 @@ private void OnGUI() {
if (GUILayout.Button("Apply") || (e.isKey && e.keyCode == KeyCode.Return)) {
target.name = input;
NodeEditor.GetEditor((XNode.Node)target, NodeEditorWindow.current).OnRename();
AssetDatabase.SetMainObject((target as XNode.Node).graph, AssetDatabase.GetAssetPath(target));
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(target))) {
AssetDatabase.SetMainObject((target as XNode.Node).graph, AssetDatabase.GetAssetPath(target));
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
}
Close();
target.TriggerOnValidate();
}
Expand Down

0 comments on commit b23e769

Please sign in to comment.