Cascading assets?

so, we have a dialog and we added dialog nodes under it,
I have a third class, which is also a scriptable object, and I want it to be under the node, how can it be done? the only thing I am able to do is adding it to the dialog (even if I give the node as the asset)


You can store any asset inside of the dialogue, but it might not necessarily be easy to access it…

Is the third class related to dialogues?

You’ll need to manage displaying it in the EditorWindow, as well…

Let’s start with a look at what you’re trying to add…

the third class is the “choice”, all it has is a string and it is a choice of answer that the player can choose.

using UnityEngine;
using System;
namespace Nomad.Dialog
    [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>();
           = 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.

any idea?

I think I misunderstood what you’re reaching for…
You cannot nest the assets… all assets saved under a root asset the way we’re doing the Dialogue/DialogueNodes are restricted to being on the first level.

ok thanks