Uielements.Toolbar is innacessible

im following this video

and am at 11:44 and have come into the issue of “var toolbar = new Toolbar()” where Toolbar is inaccesible, ive tried adding the namespace UIElements before it and have done quite a bit of research looking for a solution and came to a post saying the feature had been deprecated for the newer toolbar overlay feature.

is this my issue? am i missing something? have i just not understood this Unity - Scripting API: Toolbar

i would appreciate any help on this issue as all googling of the issue has been mostly useless due to the specificity of the issue and the fact the word toolbar often turns up information relating to the toolbar of the engine itself.

heres my code just for reference

using UnityEditor;
using UnityEditor.Experimental.GraphView;
using UnityEngine.UIElements;

public class DialogueGraph : EditorWindow
{
private DialogueGraphView _graphview;

[MenuItem("Graph/Dialogue Graph")]
public static void OpenDialogueGraphWindow()
{
var window = GetWindow<DialogueGraph>();
window.titleContent = new GUIContent(text: "Dialogue Graph");
}

private void OnEnable()
{
ConstructGraphView();
}

private void ConstructGraphView()
{
_graphview = new DialogueGraphView
{
name = "DialogueGraph"
};

_graphview.StretchToParentSize();
rootVisualElement.Add(_graphview);
}

public void GenerateToolbar()
{
// THIS IS MY PROBLEM LINE
var toolbar = new Toolbar();
}

private void OnDisable()
{
rootVisualElement.Remove(_graphview);
}
}```

Can you share exactly what your error message is?

the error message is “Toolbar is innacesible due to its protection level”

for anyone coming across this the issue i found to fix this was to chane Toolbar() to UnityEditor.UIElements.Toolbar() as the issue was that the compiler was assuming it to be unity engine toolbar not unity editor toolbar

2 Likes