DialogNodes erased after file is named

I’m also running into the issue where the dialog nodes created in Awake() are deleted as soon as the editing of the new Dialog file is finished. When you create a new one, it wants you to type in a name for the file. Once you hit enter on that, whether given a new name or not, the dialog nodes disappear. A new root node has to be added via the inspector and doesn’t get a GUID for its Id as a result.

I see people complaining about this in 2021 and 2022 unity. Has a solution been found?

If I recall correctly, there is a fix for this a bit later in the course

1 Like

I got stuck and was unable to proceed after ‘Dialogue Node Scriptable Object’ since I could generate new dialogs any more. I was able to come up with the following solution in DialogEditor.OnGUI() that resolved the issue:

else
            {
                if(selectedDialog.GetAllNodes().Count == 0)
                {
                    selectedDialog.CreateNode(null);
                }
                ProcessEvents();

It’s hacky, but it adds a root node if one is missing.

For now, this is a good solution (this issue doesn’t happen with everybody at this stage, in fact, I haven’t seen it in quite a while). Later in the course, we’ll be using the OnBeforeSerialize method and eventually be saving the nodes as child objects in the Dialogue file. Once we do, this fragment of code will become redundant.

OnBeforeSerialize fix made things usable again, but there are still a bunch of errors.

I’ve spent some time digging around and it seems the OnBeforeSerialize and OnAwake logic doesn’t generate a save as they occur in that brief time window in which the Asset has been created, but not given a file name. Any changes during that time are revoked when the file is named and officially flushed to disk. I’ve gotten around most of the problems with lazy loads and safety checks but I think the course is due for an update. It seems to be the source of this issue, the broken file pointer errors, and the Validate errors that occur when you first create a dialog.

The good news is that students only run into these issues if they create new Dialog objects in the Unity Editor, If you just keep the one dialog object around as he does in the videos then you won’t experience the problems until you use the code in the wild.

Which version of Unity are you using? I’m not experiencing this issue in my clones of the course in several 2021 versions as well as 2022.1.5f.

I’ve had it in 2022.9, 22022.11, and 2022.13 so far. I haven’t tried it in the older versions yet.
It all worked great until I decided to delete and recreate the dialog object.

Hmm… I ran the course project in Unity 2022.11f, and I did encounter an error on creating a new Dialogue and renaming it, but in the Inspector window (not the Dialogue Editor), a node with a name does exist, and once deselecting and selecting the new Dialogue it appears normal in the DialogueEditor.

I’ll have to do some research to figure out a fix to eliminate the error. In the meantime, deselecting and selecting the newly created dialogue should do the trick.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms