Hello!
I’m trying to draw a rectangle with GL inside of a TwoPanelSplitView, but my window ends up completely black when I use GL.Clear, rather than just the area inside the panel. What am I doing wrong?
Thanks!
Code for reference:
private void HandleDrawing()
{
if (Event.current.type is EventType.Repaint)
{
_width = position.width;
_height = position.height;
_shader = Shader.Find("Hidden/Internal-Colored");
_mat = new Material(_shader)
{
hideFlags = HideFlags.HideAndDontSave
};
_mat.SetPass(0);
GL.PushMatrix();
GL.Clear(true, true, Color.black);
GL.PopMatrix();
Handles.EndGUI();
}
}
private void Update()
{
Repaint();
}
public void CreateGUI()
{
// Each editor window contains a root VisualElement object
VisualElement root = rootVisualElement;
// Separate the window into variables and plot
var splitView = new TwoPaneSplitView(0, 200, TwoPaneSplitViewOrientation.Horizontal);
splitView.usageHints = UsageHints.GroupTransform;
root.Add(splitView);
// Panels from the splitview
var leftPane = new VisualElement();
splitView.Add(leftPane);
var rightPane = new VisualElement();
rightPane.usageHints = UsageHints.GroupTransform;
splitView.Add(rightPane);
// Add a GameObject to expose possible variables
var gameObjectField = new ObjectField("Object to analyze");
leftPane.Add(gameObjectField);
var glContent = new IMGUIContainer(HandleDrawing);
glContent.usageHints = UsageHints.DynamicColor;
rightPane.Add(glContent);
}