I am drawing arrows using IMGUI in a IMGUIContainer. However, since my custom editor supports panning and zooming, the arrows clip over the menu bar, which I want to avoid.
In the following image, the blue selected IMGUIContainer is the default one, while the VisualElement called AIEditorCanvas is the IMGUIContainer class in which I draw the arrows. The latter has a width and height of 0 though, as it only really acts as the parent of all the nodes and as a canvas to draw the arrows.
Setting overflow to hidden leads to all my arrows disappearing, since the container has a size of 0. I cannot make the canvas the size of the window, as it is being transformed by the user, i.e. panning and zooming leads to the canvas moving or scaling, and together with it, all its children (the nodes). Giving the canvas a fixed size would lead to arrows not being drawn outside the canvas, which could be the case in a big tree.
My problem is a bit specific and complicated to follow along, but I appreciate any advice on how to go about this. I am sure that I am misunderstanding a few aspects of IMGUIContainers here.
If not you can add a VisualElement that act as a viewport (maybe AIEditorBackground) that is not affected by zoom/pan and set “overflow: hidden” on it.
I’d like to point out that the official docs for IMGUIContainer are literally useless - even now in late 2020: https://docs.unity3d.com/Manual/UIE-IMGUI.html talks about things without ever documenting ANYTHING, and the script docs are missing entirely (it’s just a list of method names: Unity - Scripting API: IMGUIContainer - someone wrote literally 5 words as the sum total of the docs for that class :(. The doc for the Constructor is particularly hilarious: “Constructor” ← are Unity staff trolling us now? ).