Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Serialization error with VisualElements

Discussion in 'Scripting' started by celinedrules, Aug 28, 2022.

  1. celinedrules

    celinedrules

    Joined:
    Jan 31, 2013
    Posts:
    16
    I am getting an error in my custom editor window 'DialogueGraph' telling me that VisualElementCreation is not allowed to be called during serialization. Any visual elements that I am creating are being done in OnEnable() so I am confused as to why I am getting this error. Everything does work as it's supposed to though.

    I did have the same error in another class but I was able to fix it by removing the serialized field referencing my GraphView even though that value was never actually set anywhere. So this led me to believe that it could be a serialized field in my editor window but even if I remove any serialized fields, I still get the error.

    UnityException: VisualElementCreation is not allowed to be called during serialization, call it from OnEnable instead. Called from ScriptableObject 'DialogueGraph'.
    See "Script Serialization" page in the Unity Manual for further details.
    UnityEngine.UIElements.VisualElement..ctor () (at <107446276b724792a53cd389e03a278b>:0)
    UnityEditor.Experimental.GraphView.GraphElement..ctor () (at <cafc87908f9140d9ac76ae59a6a95128>:0)
    UnityEditor.Experimental.GraphView.Node..ctor (System.String uiFile) (at <cafc87908f9140d9ac76ae59a6a95128>:0)
    UnityEditor.Experimental.GraphView.Node..ctor () (at <cafc87908f9140d9ac76ae59a6a95128>:0)
    ModernDialogues.Editor.DialogueNode..ctor () <0x148fa5a3690 + 0x00052> in <1ef617d1ccbe42f4bcdc4736f159f636>:0
     
  2. nvidialover

    nvidialover

    Joined:
    Aug 12, 2020
    Posts:
    6
    Did you fix it? I'm also encountering this issue and have no idea how to procede.