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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Looking for advice on a how to setup the GUI

Discussion in 'Immediate Mode GUI (IMGUI)' started by Michael-Ryan, May 28, 2009.

  1. Michael-Ryan

    Michael-Ryan

    Joined:
    Apr 10, 2009
    Posts:
    184
    I am currently working on a non-iPhone game editor, and have been using the GUI and GUILayout systems for the editor's interface.

    Unfortunately, I have already encountered a number of issues that I find extremely frustrating. I have submitted inquiries on the forum, but have not yet received any replies.

    Should I be using the old GUIText/GUITexture/GUILayer system instead? I'd rather use the new system, since I suspect it will be better supported, but I'm finding it rather difficult to get around some of these issues, namely mouse events falling through to lower-level GUI elements.

    If there is a GUI.Box rendered above a GUI.Button, the mouse should not affect the lower button in any way. Currently, the button receives mouseOver/Out and click events, and I have found no way of preventing that.

    I've found similar complaints about events falling through, and even saw that it was a "common issue". If it's so common, why isn't there a single mention of this in the GUI Scripting Guide? I mean, this seems like a pretty serious issue. If I have a Box and Button layered over another button, I do not EVER want the button underneath to be affected by mouse clicks or movement. I've even encountered situations such as two buttons being somewhat overlapped (button B is rendered over button A), and yet when I click button B in the intersecting region, button A is the one that gets hit even though both play the MouseOver and Click events. That doesn't make any sense, and default GUI behavior should prevent that from happening.

    There's also the issue of the iPhone not supporting any or some of the newer GUI features, or even OnMouseDown/Up. I'm finding snippets of information in various forum posts, yet there are no solid, official documentation on most of these systems.

    Now for a little rant ...

    How frequent are Unity updates released, and can we expect any better documentation in the near future? Given that multiple scripting languages are supported by Unity, the documentation should provide examples (even small ones) for every single function it features, ideally in every scripting language supported.

    Most of the code examples that currently exist focus on the basic functions. Yet when you get beyond the basics, you're forced to rely on the forum for insight into how the other systems work.

    For example, the scripting reference has only this to say about GUI.ScrollTo, "Scrolls all enclosing scrollviews so they try to make position visible." That's all well and good, yet there is not a single example showing how it actually works, and until my post yesterday, there were ZERO posts regarding this function in the forum.

    It would be great if the team could dedicate someone to go through the scripting reference pages and include some examples ... Or at least provide a community wiki so the community can add examples to the scripting reference guide. Digging through forums for information regarding scripting functionality is becoming painful.
     
  2. DrHotbunz

    DrHotbunz

    Joined:
    Feb 14, 2009
    Posts:
    315
    Sounds like your problem is in design. Redesign your menus so you do not have things over top of your buttons. Buttons go on the top. Use the Gui.depth command to ensure they render in the correct order. Use GUI Layout for most everything.

    As far as your frustration, I would suggest that you either funnel your frustration into active problem solving or give up game development. After all our beloved pass time is nothing more then solving one problem after another forever.
     
  3. Michael-Ryan

    Michael-Ryan

    Joined:
    Apr 10, 2009
    Posts:
    184
    Thanks for the advice, doc.

    I guess folks should just stop using floating, movable windows, because then you might end up in a situation where buttons overlap! Who cares if the developers spent hours implementing the system. They never really expected anyone to use them. Right?

    A statement like that might make one wonder when they could expect an update, which is exactly why I asked, "How frequent are Unity updates released?" Epic releases monthly code drops of Unreal Technology, and other tech developers do something similar.

    Sure, I could manually disable lower-level GUI elements by setting GUI.enable to false, but that shouldn't be necessary. They modeled the GUI system loosely on web browser renderers and CSS. In CSS, if you have a button partially overlapping another button, and you click in the intersection, only the button on top will be affected. And the ":hover" pseudo-class doesn't trigger on the lower button at all unless the mouse is directly over it, and only it. Heck, if you place a DIV container with a transparent background over the two buttons, they will render fine through the transparent DIV, but they receive NO mouse events because everything is blocked by the DIV.

    Going back to my original question, many people seem to suggest using the old GUI system to get around some of these issues or when creating GUIs for iPhone. Others seem to have created their own GUI manager using either the old GUI elements (GUITexture, etc) or have completely implemented their own GUI system from scratch using 3D quads.

    We are evaluating Unity to determine whether or not it will provide what we need for our project, but also to determine the amount of resources that will be needed to customize or replace existing systems. At this point, it seems we may have to develop our own GUI system to avoid spending hours experimenting with the existing system simply because many of its features remain undocumented, and because the old system is deprecated and may eventually be removed.

     
  4. Artial

    Artial

    Joined:
    Dec 27, 2008
    Posts:
    22
    One more vote for fixing these unwanted mouse events (especially the hover event) on background GUI elements soon!

    We are one week away from the master of a commercial game, and this is the last thing I couldn't fix or find a workaround. Too bad!
     
  5. DrHotbunz

    DrHotbunz

    Joined:
    Feb 14, 2009
    Posts:
    315
    Well perhaps its an issue you can not overcome. I have a nice GUI and its quite complex with no such issues. But then I don't have movable windows.

    Let us know how it turns out for you. Good luck.
     
  6. Slem

    Slem

    Joined:
    Jan 28, 2009
    Posts:
    191
    I must agree with the threadstarter that this is just something you just shouldn't have to workaround.
     
  7. android

    android

    Joined:
    Feb 9, 2010
    Posts:
    11
    Any progress made on this issue? I'm facing the same problem.
     
  8. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    I've referred this on to one of our GUI developers. On the other issue of documentation, we do now have someone thoroughly overhauling the docs and expanding the code examples. The updated docs are expected to be ready soon.
     
  9. rytis

    rytis

    Guest

    Joined:
    Jul 11, 2008
    Posts:
    138
    So far nothing new on this. You can either use GUI.depth or render stuff in GUI.Window (which handles z-order correctly)
     
  10. android

    android

    Joined:
    Feb 9, 2010
    Posts:
    11
    Ok.
    With GUI.depth (correct me if I'm wrong), I have to use it in separate OnGUI calls for it to work properly?
     
  11. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Yes - you can only have one OnGUI function per script.
     
  12. Narae

    Narae

    Joined:
    Mar 14, 2012
    Posts:
    4
    and 3.5.1 is out, this issue does not yet seem to be solved(although in the post above it mentions plans for solving it a long time ago), could we expect it to be in the future or should I just be using the hacks on answers to go about fixing this myself?