Error whilts creating Dialogue Unity 2023.1.9f1

I’m implementing Dialogue scripts to my project. I’m using Unity 2023.1.9f1
I’ve got this annoying little bug. When I’m creating new Dialoge errors pops up:

[Worker0] MissingReferenceException: The variable nodes of Dialogue doesn't exist anymore.
You probably need to reassign the nodes variable of the 'Dialogue' script in the inspector.
UnityEngine.Object+MarshalledUnityObject.ThrowNullExceptionObjectImpl (System.Object obj) (at <affe600311164ff58161da271ceee4f0>:0)
UnityEngine.Object+MarshalledUnityObject.MarshalNullCheck[T] (T obj) (at <affe600311164ff58161da271ceee4f0>:0)
UnityEngine.Object.GetName (UnityEngine.Object obj) (at <affe600311164ff58161da271ceee4f0>:0)
UnityEngine.Object.get_name () (at <affe600311164ff58161da271ceee4f0>:0)
RPG.Dialogue.Dialogue.OnValidate () (at Assets/Scripts/Dialogue/Dialogue.cs:25)
RPG.Dialogue.Dialogue.OnEnable () (at Assets/Scripts/Dialogue/Dialogue.cs:17)

This is what happens on those lines
obraz

When I clear console, and click over dialogues - error doesn’t appear anymore.

I’ve cheked out “17 Conversant Names” commit from Git, and it works fine. No such errors in sight.
The commit uses 2020.1.3f1 version of Unity.

I realizied the behaviour is somewhat different. When I’m creating new dialogue in my project and then click away it automatically saves the root node.

errors1

In RPG course root node is saved only after I press CTRL+S.

EDIT: I think it’s Unity problem. I’ve tried to copy paste code from Git, compare it and use it. No changes.

It is, indeed, a Unity problem. This is happening because of the way that Unity handles new assets. Before the asset is given a name (while it’s New Dialogue with the name selected until you hit enter, it exists but only partially, and that existence is in one thread while the renaming is in another thread. Once the item is renamed, the code is still running but the temporary copy is destroyed in favor of the new copy which no longer has the node created when the Dialogue was created.

Try adding this after the else clause in DialogueEditor before ProcessEvents()

                if (selectedDialogue.GetAllNodes().FirstOrDefault() == null)
                {
                    selectedDialogue.CreateNode(null);
                }

Note that this will NOT eliminate the error. There simply is no eliminating that initial error. I tried six ways till Sunday, and it just isn’t going to go away. You will, however, have a node once it’s all over.

Thanks for trying. Without the addition you proposed I already had root node created. I guess I will just have to live with that until next Unity version. :frowning:

It’s been a bug for quite a while. What changes is whether or not you need the patch to get that first node.

1 Like

Privacy & Terms