Adding new menu options to node editor
Posted: Wed Apr 17, 2024 12:40 pm
Hi, I'm trying to add more options to the node Editor to make iterations faster for our game.
I managed to do the change required by modifying the DialogueEditorWindowConversationNodeEditor.cs file and adding a empty method so I can get an error if an update overrides my changes.
My question is: Is there a cleaner way to achieve what I'm trying to do or any recommendation for custom changes?
(I discarded the idea of adding the field in a template as I don't want for each node to have a field that is not used often)
I managed to do the change required by modifying the DialogueEditorWindowConversationNodeEditor.cs file and adding a empty method so I can get an error if an update overrides my changes.
Code: Select all
....
AddCustomOptionsFromExternalProject(contextMenu, entry);
AddCanvasContextMenuGotoItems(contextMenu);
contextMenu.AddSeparator(string.Empty);
contextMenu.AddItem(new GUIContent("Play From Here..."), false, PlayConversationFromEntry, currentEntry.id);
contextMenu.ShowAsContext();
contextMenuPosition = Event.current.mousePosition;
EditorZoomArea.Begin(_zoom, _zoomArea);
}
private const string InterrogationActionId = "InterrogationActionId";
private const string InterrogationPressValue = "0";
private const string CustomFieldType_InterrogationActionId = "CustomFieldType_InterrogationActionId";
private void AddCustomOptionsFromExternalProject(GenericMenu contextMenu, DialogueEntry entry) {
contextMenu.AddSeparator(string.Empty);
void MarkAsInterrogationPress(object o) {
DialogueEntry entryToMark = o as DialogueEntry;
if (entryToMark == null) {
return;
}
Field foundField = null;
foreach (Field field in entry.fields) {
if (field.title != InterrogationActionId) {
continue;
}
foundField = field;
break;
}
if (foundField != null) {
foundField.value = "0";
return;
}
entry.fields.Add(new Field(InterrogationActionId, InterrogationPressValue, FieldType.Number, CustomFieldType_InterrogationActionId));
}
contextMenu.AddItem(new GUIContent("Mark as Interrogation Press Node"), false, MarkAsInterrogationPress, entry);
contextMenu.AddSeparator(string.Empty);
}
public static void EnsureCustomChangesAreThere() {
}
(I discarded the idea of adding the field in a template as I don't want for each node to have a field that is not used often)