Search Unity

[Official]New UI System.... coming in Unity 4.6

Discussion in 'General Discussion' started by Tim-C, May 28, 2014.

  1. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    There is a 4.6 Beta thread that tells how. It's not hard, JustSomeVeryLongFunctionCallName() that I don't remember.
     
  2. Luiz_Thiago

    Luiz_Thiago

    Joined:
    Feb 27, 2013
    Posts:
    32
    Ty dude =)
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    EventSystemManager.currentSystem.IsPointerOverEventSystemObject()

    But this thread is not the best place for this sort of discussion - you'll get better results in the beta forum.
     
  4. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    You need the "using UnityEngine.UI;" at the top. The UI stuff is in a separate namespace that isn't included in new scripts by default (since it isn't as common as UnityEngine and System.Collections).
     
  5. lyh1

    lyh1

    Joined:
    Jun 30, 2010
    Posts:
    92
    I have problem with Dynamic Font and UI Mask, it seems the Dynamic Font using a shader which is not supported by UI Mask or Dynamic Font use a wrong shader which is not support stencil buffer.
     
  6. lyh1

    lyh1

    Joined:
    Jun 30, 2010
    Posts:
    92
    I found that I need to create another material instead of using the one come with font in order to use in new UI System.
    Is it by design?????
     
  7. Ankit-Priyarup

    Ankit-Priyarup

    Joined:
    Mar 7, 2013
    Posts:
    52
    Hey,
    I am creating a chat application in Unity but i am facing an issue i.e. in gameplay window everything is perfect but when i build my app and test it on my Nexus 7 tablet everything seems to be soo tiny...
    Although i used the same aspect ratio of my table to the unity game window but still it happens. this problem carry on with my wp8 phone also.
     
  8. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,119
    You used the same aspect ratio, but which resolution did you use to design your UI?
    Take a look at the ReferenceResolution component (you can find more info in the offline documentation that comes with the Unity 4.6 beta).
     
  9. amcneilly84

    amcneilly84

    Joined:
    Aug 12, 2011
    Posts:
    8
    Hello, i am unsure how using the new GUI in 4.6 to dynamically create GUI elements in a scrollable grid. I am having alignment and scaling issues and finding that i can build for a fixed resolution but supporting multiple resolutions is proving to be difficult and complicated. any advice would greatly be appreciated given the limited documentation.

    What i want is to have a grid of buttons. this grid of buttons is 10x4 and is designed to be scrolled left and right as not all buttons will be visible at a time (4x4 buttons will be visible at a time).

    The current way i have implemented this is to create a prefab for the button. root is a empty game object with no GUI. the child is a button, that uses WDelta and HDelta of 100x100, pivot of 0.5, 0.5 and custom anchor settings. The reason for the parent object is so that the delta, pivot and anchor are relative to the parent object. I then dynamically create the elements and add them to a root GUI element with 100% width and heigh stretch, this root object has the pivot set to top left that defines the initial position of the first button. as i create the buttons i shift the next button along the x axis for each row.

    I was having issues using this method with scaling and padding i.e. the grid did not have the same proportions when the resolution was changed. to correct this i resize the GUI button width and height by the default resolution ratio and the current resolution. i also apply scale to the value i shift the buttons along the x axis.

    Now this method seams overly complicated and i suspect there is an easier way. Any advice?

    Thanks in advance
     
  10. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Aurore likes this.
  11. Venged

    Venged

    Joined:
    Oct 24, 2010
    Posts:
    500
    Is there a way to access individual Blenshape Slider values in the SkinnedMeshRenderer of an object? I would like to use the Sliders in the new GUI to access and change the Blenshapes with the GUI sliders.
     
  12. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
    I think you'd need a little bit of glue code for that - you probably can't hook the sliders to the blend shape values directly - but it's certainly doable.
     
    Venged likes this.
  13. Ankit-Priyarup

    Ankit-Priyarup

    Joined:
    Mar 7, 2013
    Posts:
    52
    Any idea about how to make blur Image element of gui. for example in the below image there is a bottom pane which has less opacity i want it to be translucent like in ios 7.
     

    Attached Files:

  14. Ramcat

    Ramcat

    Joined:
    Aug 16, 2014
    Posts:
    95
    @Tim C said:
    "Mouse clicks go though the standard input handling. It doesn't prevent clicks going through to the scene view (we don't consume the click), but in the game you can query the event system to ask it if the pointer is over an event system object."
    I would love to see some example code. I'm new to Unity and have been searching for hours on how to "query the event system to ask it if the pointer is over an event system object".
     
  15. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    Code (CSharp):
    1. bool yes = EventSystemManager.currentSystem.IsPointerOverEventSystemObject();
     
    Ramcat likes this.
  16. Ramcat

    Ramcat

    Joined:
    Aug 16, 2014
    Posts:
    95
    Thanks, just would add that you have to import UnityEngine.EventSystems as well.
     
  17. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    Well, yes :)
     
  18. Aurore

    Aurore

    Director of Real-Time Learning

    Joined:
    Aug 1, 2012
    Posts:
    3,106
  19. Robota

    Robota

    Joined:
    Feb 7, 2012
    Posts:
    82
    Ok, so we are no more in summer and 4.6 is still not released...
     
    shkar-noori likes this.
  20. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    http://unity3d.com/unity/beta/4.6

    It is in beta, yes it is not yet released. It is good that it is not yet released, because there are still bugs.

    Just as a quick note. Many of us are extremely happy that Unity wants to communicate more open. Please don't destroy that by complaining about not met release dates!
     
    Last edited: Sep 22, 2014
    shkar-noori and StarManta like this.
  21. Robota

    Robota

    Joined:
    Feb 7, 2012
    Posts:
    82
    It was a sort of joke. :)
    I'm on a project and I need 4.6 for UI. I started using the beta, and I'm happy with it. They done a really good job.
    But I'm lucky because the deadline of this project is months ago, I'am sure there are others developers that don't have my luck and are really stressed and pray for a imminent released of the 4.6.
     
  22. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    One of the golden rules of using pro software is, if it's not out right now, don't bet your business on it being out at any time. I have been using the 4.6 beta in production, but if you're not comfortable taking a risk like that and have a production on a deadline, then go grab a copy of NGUI. It's as simple as that.
     
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    There's nothing stopping anyone from using 4.6 now, unless there's some critical bug that you can't work around. It's released for all intents and purposes, aside from the webplayer maybe. Honestly the difference between the beta and the final version is arbitrary to some extent, where they decide that it's stable enough, but it doesn't mean it's "done" or there are no bugs. All "final" versions have had known bugs, it's just that they basically have to say "good enough!" at some point. So don't get too hung up on the beta label.

    No you don't. There have been many thousands of Unity games released before 4.6. If the beta didn't exist, you could use the existing UI functions, roll your own solution, or buy one off the asset store, like everyone else has done so far.

    --Eric
     
    shkar-noori likes this.
  24. Robota

    Robota

    Joined:
    Feb 7, 2012
    Posts:
    82
    I do. I have already invested time to learn uGUI. I have used nGUI one time and I was frustrated by the messy documentation. Maybe it is better now but I don't want to use it again, and yes I know that ArenMook also worked on uGUI.

    Saying that you don't need a tool to make a game because plenty of other games where made without it, is a argument a little bit to easy. So maybe you don't need Unity because a lot of games were made before Unity. Yes it is surely true...
     
    shkar-noori likes this.
  25. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    I do not think this word means what you think it means. By what seems to be your definition of the word 'need', for example, I could not have possibly integrated AR or the Facebook SDK into my games because the documentation for those plugins was subpar. If you can't deal with a component having poor documentation or unexpected gaps in functionality or being organized in a way that doesn't make sense to you? You're in the wrong industry, brother.

    Want. Want is the word you're looking for.
     
  26. Robota

    Robota

    Joined:
    Feb 7, 2012
    Posts:
    82
    Yes, surely.
     
  27. freso

    freso

    Joined:
    Mar 19, 2013
    Posts:
    73
    What is the magic behind minimizing draw calls? My current uGUI is using 7 draw calls, and I would like to get this down to 1 if I can. What should I think about?
     
  28. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Legend

    Joined:
    May 5, 2014
    Posts:
    1,485
    We are going to need WAY more information if anyone is going to help with your question.
    - Do you have a screenshot of your UI?
    - How have you built-up your UI structure?
    - Are you using the Sprite packer?
     
  29. freso

    freso

    Joined:
    Mar 19, 2013
    Posts:
    73
    I was looking for some generic tips, but I can go specific for my case.
    I'm doing a HUD for a car game (see screenshot).
    There are 4 Text-components that uses the same font (TTF), and 4 image components.
    The images are single PNG:s (transparent) imported as "Sprite 2D and UI)
    Not using Sprite Packer. I thought I read that the images would be packed automatically in runtime. uGUI_question.png
     
  30. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,659
    Only in Unity Pro.
     
  31. Andy-Touch

    Andy-Touch

    A Moon Shaped Bool Unity Legend

    Joined:
    May 5, 2014
    Posts:
    1,485
    Yeah, the Sprite Packer is a Pro Feature that takes your individual sprites (That have been assigned a Packing Tag in the import settings) and would auto-pack them into a spritesheet, that would reduce the number of drawcalls.

    However, if you are using Unity Free, you could use something like ShoeBox (http://renderhjs.net/shoebox/) which is a useful tool that allows you to auto-create a spritesheet based on selected images. This spritesheet can then be imported into Unity under a 'Multiple' sprite type, and you can then use the Sprite Editor to slice it into individual sprites.

    I just did this with a few sprites from a Flappy Bird Spritesheet, no Sprite Packer used!:
     

    Attached Files:

  32. freso

    freso

    Joined:
    Mar 19, 2013
    Posts:
    73
    Oh, that I totally missed.

    Ok, so in Unity Free, I should create a sprite sheet to minimize drawcalls för images.
    How stupid of me. I thought I tested some variants, but I see now, if I remove all images, I have only one draw call.

    Thanks for your answers. It's all logical now. :)
     
  33. thendricks

    thendricks

    Joined:
    Aug 14, 2012
    Posts:
    48
    Is there a way to do multiple touch on the new GUI system because I have a mobile game with a joystick and I can't move the joystick and press a different button at the same time
     
  34. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    Think about optimizing other areas of your game, maybe?

    At just 7 draw calls, the draw calls are unlikely to be a bottleneck. If your UI is slow, it's more likely to be related to the number of pixels (alpha/overdraw), or the number of polygons, or other factors (e.g. dynamic fonts updating)
     
  35. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    378
    Same question... there is 4.6 RC1 already! Is it fixed?
     
  36. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Not sure if it has been asked before.
    Will there be (or is there already) some kind of customizeable grid to be used when layouting the user interface structure?
    What I'd like to see in the new UI system is some kind of rulers or grids that we can drag around to create a framework for our interface elements so we can simply snap things into place.
     
    Devil_Inside likes this.
  37. dcc7

    dcc7

    Joined:
    Sep 22, 2014
    Posts:
    2
    The new UI button does not work.
    - Unity3D 4.6 rc2
    - Windows Phone 8.1 emulator
     
  38. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    You should think about whether the 6 draw calls you're thinking about saving are worth the effort. First question is, are you even bottlenecked by draw calls?

    I'm pretty sure that the "1 draw call" selling point for UIs is purely a marketing thing. It can be a genuine concern for some mobile games but, even there, it's mostly a concern for really dated hardware (eg: early iPhones where 30 draw calls total was pushing it).
     
    giyomu likes this.
  39. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    It may have been 3-5 years ago. Today it just shows that the person using this to market their product hasn't updated their materials in a long time (or hasn't kept up with technological developments in the mobile world). Unless you're having many hundreds of draw calls (or target people with devices from the previous age), I really wouldn't worry about it. Just because it's comparatively simple to optimize doesn't mean it's worth it.
     
    angrypenguin likes this.
  40. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    I don't think it's even necessarily "comparatively simple to optimize". If I need to save draw calls I'm going to look at my scene, not my UI, because if it's worth the bother of optimizing anything I'm going to want to save way more than just a handful, I'm going to want to make changes that save a whole bunch at once, and I'm going to want to make changes which have little or no visual impact.

    A UI with less than a dozen calls doesn't fit those criteria, because the most I can save with my effort is less than a dozen calls. Spend the same time looking for and finding inefficiencies in my scene and I could save many times that with similar effort and less functional/aesthetic impact.

    I think what makes it a popular optimization is that people have heard so much about it. A common complaint with the legacy GUI system is its number of draw calls, so people heard about that and the huge savings you could make with potentially simple changes (eg: bake anything that doesn't change into textures... bam, save 20+ draw calls at once!). In response people started marketing 3rd party systems as "saving draw calls" which quickly rushed to "entire GUI in 1 draw call" claims, which is reasonable when considered in context (it's a direct solution to a real problem) but isn't a useful yardstick in the context of optimizing a game as a whole (because by using such a system you've already gone from potentially many dozens of draw calls to probably less than one dozen, so now it's probably time to look elsewhere).

    As with all things optimization, it's absolutely critical to measure before, during and after, and to make sure you understand all of what you're optimizing before you jump in. Otherwise there's a string likelihood you'll make stuff worse.
     
    jashan and inafield like this.
  41. Marrt

    Marrt

    Joined:
    Feb 7, 2012
    Posts:
    613
    Absolutely, if you are on mobile overdraw is your bane.
    Someone said (in a thread i cannot find anymore) that future releases will contain an option to render non-Quad geometry in the UI-System to reduce overdraw (Just like the SpriteRenderer does)

    I couldn't wait, and since SpriteRenderers can be tossed onto RectTransform Objects i just wrote a function that adds a SpriteRenderer-child to a UI-Image essentially replacing the high-overdraw quad with a low overdraw Spriterenderer
    Pics in that post:
    http://forum.unity3d.com/threads/overdraw-spriterenderer-in-ui.339912/#post-2202994
    -If you need to scale the UI-Image at runtime by Anchor-manipulation you need to re-scale the SpriteRenderer-child accordingly, also the Spriterenderer is always centered within the anchors which may break some configurations.
     
  42. Whippets

    Whippets

    Joined:
    Feb 28, 2013
    Posts:
    1,775
    @martt nice necro answer to a near year old post XD
     
  43. Marrt

    Marrt

    Joined:
    Feb 7, 2012
    Posts:
    613
    Yet, overdraw caused by quads is still an issue on mobile, and i posted a neat workaround, i believe.
     
  44. matdestr

    matdestr

    Joined:
    Jul 18, 2016
    Posts:
    3