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. Dismiss Notice

I still don't like the new GUI system

Discussion in 'General Discussion' started by Tomnnn, Dec 5, 2014.

  1. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    I've messed with the canvas scalar and the anchor points and blah blah blah but I still cannot get the functionality and control I have with the legacy system. I can define the positions and dimensions of screen components in the legacy system with screen percentages. I don't know why but I just can't work with the new stuff. I try my menu in another ratio and the content flies off the panel. I've got screenshots this time to accompany my dislike.

    I've got the settings I was using on the canvas / canvas scalar and my very basic menu at different screen ratios, then the rest of those shots are just humorous & bad attempts to have things scale.

    I don't want my buttons to get pushed off the screen when the resolution changes...
    I don't want my buttons to become huge when the resolution changes...
    I don't want my buttons to flatten or stretch when the resolution changes...
    I want my buttons to be a percentage of the panel they're on and be that percentage at every resolution known to man. The legacy GUI can do this. How can this new UI be designed without the thought of supporting multiple resolutions?

    I know I'm probably just doing something wrong, but these mess ups prove the new system & the accompanying tutorials are not very clear :D

    --edit

    I've used all 3 screen space options too. The default one makes quite a huge object to overlay...
     

    Attached Files:

    Last edited: Dec 5, 2014
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,500
    My brief foray into the new GUI (about 90 minutes total) already has a multi-resolution GUI working fine. It took a few minutes of fiddling with values then trying different resolutions/aspect ratios, but that's all.

    If you want I can check my settings and let you know what they are?
     
    shkar-noori, mancuso and Tomnnn like this.
  3. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    I wouldn't mind if there was a sample project with properly scaling gui that I could look at. This is supposed to be intuitive and easy to use, right? I don't know why I can do that complicated stuff but not the easy stuff. It's that gosh darn left brain doing all the work.
     
  4. Aurore

    Aurore

    Director of Real-Time Learning Unity Technologies

    Joined:
    Aug 1, 2012
    Posts:
    3,106
    Tomnnn and mancuso like this.
  5. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    Thank you so much! I've been looking for a project making use of it properly, the only one I could find was using the "5 minute gui" using the now outdated screen resolution component... the only one I'm really stumped on lol. I know it's canvas scalar now, but I still can't get that working.

    I think I'm going to end up mixing them. For things like buttons or ui elements that need to be in certain places on the screen, I'll be using the legacy gui. For things like rendering text in the world where the position is set by objects rather than the screen ratio, I'll use the new stuff.
     
  6. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    I think you should not do that, I had my whole game UI written in IMGUI [Legacy], it took me 2 weeks to convert nearly everything to Unity UI [New], and I had to do RTL and LTR Languages support that's why it took time, and the multi-resolution stuff is easy, just build your UI while your canvas scaler's width and heigh is set to 1280x720, and it handles most of the other stuff if you anchor your elements correctly.
     
  7. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    I tried it for UI, but the only real convenience to me with the new gui stuff is world space gui that can appear above an entity. I can set the size of the element by the screen width and height, then place it above the object. The screenshots you see in the first post are working in 16:9. I didn't do much better trying to work in 1280x720 or 800x600. I've given it a decent attempt for a second time now with different kinds of anchoring and resolutions and scaling options (basically, a permutation of anchor options for each button and on all 3 of those resolutions / ratios). The results were never desirable.

    I'm okay with scripting my GUI. I do it in a way that makes it fast to develop and easy to organize. Is there any problem you think I'll run into by mixing the two? When I say that, I mean I'm going to make "popoff number" prefabs for things like damage numbers flying off an enemy. The two systems will be mixed as far as me using both, but I didn't mean to say they'll ever be interacting with each other.
     
  8. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    For my PC game, I'm designing the UI in 1920x1080 (HD 16:9) as the reference resolution, and with the Screen Match Mode set to match width or height (set to width). I've tried it from 800x600 to 4K HD and it resizes perfectly. What problems are you have with rescaling UI?
     
    shkar-noori likes this.
  9. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    I wish I knew. The screenshots I posted were from developing in 16:9 as well with the reference resolution at 1920x1080. It's fine, I think using the legacy system for screen stuff and the new system for world stuff will suit my purposes.
     
  10. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    Ah. Set camera to ScreenSpace-Overlay and the width/height slider to width - see if that helps
     
  11. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    I don't know what are you doing wrong but sounds like it you are giving up too fast and using the "what works" route which generally results in Frankenstein projects with bad performance. You did not show any picture how was you buttons or label setup?
     
  12. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    I stated that I went through a permutation of setups regarding resolutions to work on, button anchors and other things to try to make it work. I'll give it a shot in the future with the project Aurore linked and hope for the best. The screenshots I posted were from the result with the best results lol. I'm not worried about using the legacy gui for screen elements, it's never been a performance issue before.

    I followed a tutorial on making a really good setup. Something about using the camera, then switching to world space but it keeps the settings done by using the camera first, blah blah. I'll probably give it another try in unity 5. I sat there screwing with it for 4 hours yesterday so I need time away from it :D
     
  13. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    Update: getting this error when trying to add text at runtime. Not sure why. I can't even add text from the context menu. Might be a fancy new bug :)

    This one is nice because it's easy to reproduce. Make a new object, make a canvas, run the project, right click on the canvas in the editor and try to add a text object. Every other object appears to be working for me, just can't add text. You get the same error if you try to add the text via scripts.

    Cool. The one thing I thought the new gui would be useful for. ._.

    --edit

    Oh and it seems I can add some text, then duplicate it at runtime and not get this error. This is quite the interesting bug. And I ALSO just noticed that the buttons and other objects can't have text on them either lol. The editor will make new buttons during runtime, but will throw the same error if I try to click on the text.

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.UI.Text.GetGenerationSettings (Vector2 extents) (at /Applications/buildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/Text.cs:360)
    UnityEngine.UI.Text.get_preferredWidth () (at /Applications/buildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/Text.cs:469)
    UnityEditor.Events.LayoutPropertiesPreview.<OnPreviewGUI>m__A (ILayoutElement e) (at /Applications/buildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystemeditor/UI/LayoutPropertiesPreview.cs:96)
    UnityEngine.UI.LayoutUtility.GetLayoutProperty (UnityEngine.RectTransform rect, System.Func`2 property, Single defaultValue, ILayoutElement& source) (at /Applications/buildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/Layout/LayoutUtility.cs:85)
    UnityEditor.Events.LayoutPropertiesPreview.OnPreviewGUI (Rect r, UnityEngine.GUIStyle background) (at /Applications/buildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystemeditor/UI/LayoutPropertiesPreview.cs:96)
    UnityEditor.ObjectPreview.OnInteractivePreviewGUI (Rect r, UnityEngine.GUIStyle background)
    UnityEditor.ObjectPreview.DrawPreview (IPreviewable defaultPreview, Rect previewArea, UnityEngine.Object[] targets)
    UnityEditor.ObjectPreview.DrawPreview (Rect previewArea)
    UnityEditor.InspectorWindow.DrawPreviewAndLabels ()
    UnityEditor.InspectorWindow.OnGUI ()
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

    --edit #2

    You can get around the bug by making prefabs out of ui components and then instantiating them with GameObject.Instantiate. Interesting. Very interesting.
     
    Last edited: Dec 6, 2014
  14. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    Hmm, submit the bug as it's repeatable for you
     
  15. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    I found a workaround. The "bug" makes sense. There are certain things we don't have access to at runtime, and the canvas a UI object belongs to is one of those things. The bug comes from adding a new text component at runtime, but duplicated an existing one or instantiating a prefab that came from an object linked to a canvas does not cause the bug. It's not a bug at all, there's just an internal thing we can't see that sets the canvas a UI object will be drawn on.

    I wonder how accurate that speculation is :D
     
  16. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    I think I saw at the forum UI section once during beta that if you don't use any text it won't include font data/atlas or something automatically and then trying to add text runtime would fail on this. Not sure if it was classified as bug..
     
  17. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,789
    I recently made a GUI thinking I needed to re-anchor and set stretching and locked things to corners and edges and the bloody thing kept blowing up. I then remade it without touching a single anchor or anything,,just defaults.. The canvas scaler was set to numbers reflecting a 16:9 ration and the slider set to the left for width. That puppy held up through all kinds of resizing and stayed intact from teeny weeny to full screen and even most off ratio resizings..though they may have had some space at the top and bottom.
     
  18. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,148
    The imprecise poppyclock from the new system not being perfect and padding space around some components when I make unrealistic resolutions is unacceptable.

    Using both is going nicely. Here's a few screenshots from an idle clicker game I'm working on to take part in the hype. The UI and mob are all textures & legacy gui, the text popping up off the entity is using the new gui. They work well together :D
     

    Attached Files: