the third class is the “choice”, all it has is a string and it is a choice of answer that the player can choose.
[CreateAssetMenu(fileName = "New Choice", menuName = "Dialog/Choice", order = 50)]
public class Choice : ScriptableObject
public string choiceText;
I have a new editor, for the choice, which I launch from the dialog editor:
if (GUILayout.Button(buttonName, GUILayout.ExpandWidth(true)))
ChoiceEditor choiceEditor = (ChoiceEditor)GetWindow(typeof(ChoiceEditor), false, "Choice Editor");
and here, in the choice editor, I am creating a new choice and I want to add it as a child of the dialog node
if (selectedChoice == null)
if (GUILayout.Button("Create new choice"))
Choice newChoice = CreateInstance<Choice>();
newChoice.name = Guid.NewGuid().ToString();
selectedChoice = newChoice;
I tried AssetDatabase.AddObjectToAsset(newChoice, parentNode);
but that adds it to the dialog as a parent and not to the node.