Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Question How to have a GUI.Window pass through events e.g. scrollwheel

Discussion in 'Immediate Mode GUI (IMGUI)' started by AlexTD, Oct 29, 2022.

  1. AlexTD


    Oct 28, 2022
    I have a conundrum that seems like it should be a simple fix but I'm not seeing it.

    So first, I'm modding RimWorld, so I don't have complete control, there's a good chunk of wrapper code to GUI calls, and I'm working with what I can figure out. I've heard that IMGUI is not the way to do this. But RimWorld is old so that's how it be. So maybe it's not fixable or requires a very different approach

    My problem is with a dragging re-orderable list in a ScrollView area. The dragged item is drawn and custom reordering code works fine. The scrolling works fine. But they do not work together, not quite. See, the dragged item is drawn under the cursor with a tiny window on top.

    So this tiny floating window is blocking the ScrollWheel events from hitting the window underneath and it is not scrolling. And funnily enough, if you move the mouse fast enough and scroll, the floating window doesn't update its position immediately and the cursor ends up over the list for a moment, so then the scrolling does work.

    So, questions:

    1) How can I get a window to pass through UI events, ie ignore them entirely? Somehow, though, the mouseDrag event does go to the list and not the floating window at all. I see no reason for that, so that's awfully confusing.

    2) How does Unity decide when to call WindowFunction and with what event? It seems it should be simple enough, send input events to whatever window is in front and the cursor is inside its box .. but this tiny window is getting ScrollWheel but not getting mouseDrag. Also, I tried not calling GUI.Window during a ScrollWheel event and the WindowFunction still got called - perhaps from a previous GUI.Window call from a different event? Is RimWorld calling GUI.Window too many times, once per event, and it should only be the layout?.. I really called it quits here because I thought I had my solution. Perplexing that the WindowFunction gets called even without a GUI.Window call( Unless somehow I botched the attempt to suppress that call )

    3) Is there just a better way to draw floating temporary boxes than using a Window? Given that the rect might expand past the window it's created in.