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 id.unity.com 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.

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

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

  1. sc3

    sc3

    Joined:
    Nov 2, 2010
    Posts:
    103
    Looking really good so far. I just have a few questions, sorry if they've been explained but I missed them:

    1. Is there a way to save presets? e.g. button styles, text styles
    2. Is there a way to have a mix between pixels and percentages? e.g. make a box either 400 pixels or 30% whichever is the greater
    3. The animation system for buttons and so on is very nice but will there be "automatic" ways of setting this up, or do we have to animate each one manually every time? I'd like if there was a way to select "Highlighted" and then just pick an option like "move forward in world space by [x]" instead of having to manually do it.
     
  2. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    in watching th video w anchors can u set them at fixed offset instead of percentage from base so when the window grows the anchor will not move from base but be at that offset instead of percentage that would move to that percentage?

    i mean what if i want it always 10 pixels form some base like left side and not 10% from the left side...

    watch the video u will see why the question. cause if u cant that could be issue, nasty limitation, for no reason since it would be easy to do both other ui engines for unity do both....

    or perhaps anchors are always for percentage and there is some other way to dock or anchor always at some fixed amounts...


    also with the button being moved around could it have been entirely done using code instead of doing any animations...
     
    Last edited: May 29, 2014
  3. DalerHakimov

    DalerHakimov

    Joined:
    Mar 14, 2014
    Posts:
    302
    Outstanding... I like it very much, especially the anchor system, so we will not think about how it will look in different resolutions.. very good.
     
    Last edited: May 29, 2014
  4. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    More information on the layout system will come, but yes there is a grid layout.

    It's all scriptabe, events can be hooked up from API.

    The GUI system takes quads, you could build a quad mesh and have this be a button. Alternatively the event system can work with mesh colliders and you could just use a normal mesh.

    Not currently but it is something we would like to add in the future.

    Text is rendered line all other things in the UI system (only regenerated when it's changed) so static test will be very fast.

    Yes, this uses unity standard rich text

    We will not have this in the first version

    We have input fields, they are an additional script you attach to a Text element that allows editing. If you want to turn on / off editing you can just enable / disable the InputField component.
     
  5. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    A lot of the questions here are pretty low level, so I'll be giving short answers as we will address them more when we talk about layout and API.
    We have the horizontal / vertical layout system you are referring to. We don't currently have auto creation of scrollbars.

    It's easy to add a layout item by script, you just add it to the element that handles the layout and it will be laid out.

    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.
     
  6. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    We don't have a tweening library out of the box, but on the beta list there have been people using 3rd party tweening tools with uGUI without problems.
     
  7. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Hi, I'm not quite sure I completely understand the question, but I'll try to answer. You can create a layout in the new system where the borders you add scale with the resolution, this means that on a smaller device the borders would be smaller.
     
  8. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    We should be releasing during the summer, no specific date, just want to make sure the bugs are squished good and proper.
     
  9. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Once again this is something we will talk about more later, but the basic idea is that we have an EventSystem that input modules can be plugged into (Keyboard, mouse, controller, touch). In these modules is the logic behind what events get sent and in what order. We provide some out of the box, but we know that the modules we have are not going to be exactly what some people want so you can write your own for example for kinect or ps move. Or extend an existing one. You can also add custom events to the event system and send them from your new module.
     
  10. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    We use prefabs buttons / text for this.

    I'll have to check this with the Rune who is the layout expert. What I can say is that if it can't be done via the UI, then I know it can be done via scripting.

    We use animation clips for animation, if there is a common use case you have then it's pretty easy to write an animation you can reuse. We don't think we'd be able to cover all users 'general' cases and don't want to provide a big list of preconfigured animations. You will be able to extend the button editor an add this yourself though if you feel like it.
     
  11. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,654
    Could we use it for events that aren't input related?
     
  12. jmatthews

    jmatthews

    Joined:
    Jul 27, 2011
    Posts:
    199
    Have you guys nailed down usage of GUI elements in world space?

    I see the "click graphic" you show as an example of GUI in world space, would love to hear that you'd made a virtual keyboard or even just a single virtual button that you can push in-game showcasing a transformed GUI being used interactively.

    I'm also curious if you've opened up the shader element. Can we use whichever shader we like to draw the GUI?

    On the pointer enter and exit scenario. A common use case is to trigger a sound effect on push and release. You obviously have events bound and not exposed as you've pointed out because you have separate graphical representations built in to the property window. By way of polishing it may not be a bad idea to just expose hooks for those events in the same property window so people don't have to extend the class. I would guess that most people would be extended it.
     
  13. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Yep it works. I want to put together a demo where you can walk round and use computers / keypads but I have not had time yet :(

    Yes. One thing to note is that material changes break batching so the more materials your GUI users the more draw calls it will take.

    It's a debate about simplicity. Most likely we will include the scenario you describe in the docs.
     
  14. nipoco

    nipoco

    Joined:
    Sep 1, 2011
    Posts:
    2,008
    Watched the video. And I'm impressed.

    Good job to everyone who is involved into this.
     
  15. franktinsley

    franktinsley

    Joined:
    Jul 1, 2010
    Posts:
    130
    Has the Unity team looked into using Unity's physics components (either 2D or 3D) to add the dynamic movement to things like scrolls views with spring?
     
  16. Per

    Per

    Joined:
    Jun 25, 2009
    Posts:
    460
    Thanks for the responses Tim C, sounds great :)
     
  17. konsnos

    konsnos

    Joined:
    Feb 13, 2012
    Posts:
    123
    Really nice. Nice work guys!

    I have one question. Will it handle internally localization, or is it up to us to script it?
     
  18. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,901
    I show how to position an element a fixed amount of pixels from the left side right here in the video: http://youtu.be/EOX6itCuKOc?t=6m20s
    Anchors are always in percentages. Fixed offsets you do by moving the position of the element.

    Yes, certainly.
     
  19. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,901
    We have a ScrollRect component (used for scroll views) that supports springiness and inertia, but using a full physics engine for this would be a complete overkill.

    However, if you do want full physics for your UI, nothing is preventing you from putting 2D or 3D colliders and rigidbodies on the GameObjects that also have the UI elements, and have them be influenced by physics that way.
     
  20. franktinsley

    franktinsley

    Joined:
    Jul 1, 2010
    Posts:
    130
    Great I was hoping that's how it worked! I guess Apple has been adding more game engine style physics behaviors to iOS' UI frameworks so it occurred to me that Unity might accidentally be ahead of the pack. Sounds like it is, assuming the pack actually does move towards more physics based animation of UI. XD
     
    Last edited: May 29, 2014
  21. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,901
    Use prefabs.

    The normal RectTransform anchoring system only supports adding percentages and pixel offsets together; not using a minimum or maximum. We have a different layout system we're going to show later which can do a bit more (similar to GUILayout horizontal and vertical groups in the old GUI system, where you can specify e.g. minWidth) but it still doesn't exactly take a maximum of a pixel and percentage value, though it can do something similar. If you want exactly a maximum of a pixel and percentage value, you could write a simple script. It would only be a few lines and not have to run on every update.

    You can reuse the same animation controller for many elements so should never have to do the same setup every time.

    As for having "options" for "move forward in world space by [x]" and the million other things you might want to do on hover, I don't get the point. The way it works now is that instead of picking an options for "move forward in space" you just click the animation mode button and then actually move it forward in space, or whatever else you want it to do. It's not really more clicks and it's way more flexible.
     
  22. Cripplette

    Cripplette

    Joined:
    Sep 18, 2012
    Posts:
    66
    We will make prefab for widgets such as buttons. But If we want to create a prefab for example for a Message Window composed by other widgets, how do you make a prefab of it without loosing the link to your prefab buttons ?

    Nested prefab is a huge need in the case of UI (and in other cases anyway), can you please work on it, we need it so badly!

    Can you use the anchor system with an empty widget to organize stuff easily, make an invisible rect ?
     
    Last edited: May 29, 2014
  23. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,901
    Agreed. Nested prefabs is out of the hands of the UI Team, but it's on Unity's roadmap.

    Yes, you can use an empty GameObject with a RectTransform.
     
  24. Toad

    Toad

    Joined:
    Aug 14, 2010
    Posts:
    298
    Looks really good. Great job on this guys!

    Can't wait for more details, and it's release obviously!

    Very interested in the new event system, so I hope we get more details on this soon.
     
  25. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    wow thank! can't wait for the release / to switch to your new ui!
     
  26. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    uGUI looks very nice however WYSYWIG for text in text area seems be very rare used in most cases since it is only global effect. My suggestion - remove them completely for save space for future and better wysywig which support global and local effect. In addition - use dropdown with multiple selection for visual effect because we sometime need mix effect and dont need split work (set one effect in inspector and write html for another effect)

    Event system - add button "add new event" (onrealese and other) to gui compoment instead of forcing people write small class for simple event which seem a bit overkill for that situation - i think my propsal is better compromise for complexity vs simplicity compared to constraining to one event per ui element like in button where is only one event in inspector - onclick

    Last but not least Other features sounds promises ;)
     
  27. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    All that looks very very good so far. I actually can't wait to test this out myself.
    Thanks for communicating more with us again. I'm really looking forward to 4.6 and 5.0 :)
     
  28. Agostino

    Agostino

    Joined:
    Nov 18, 2013
    Posts:
    21
    Will there finally be a simple way of distinguishing clicks on the GUI and clicks outside the GUI?
    I mean, if a user clicks a button, I'd like that click not to "go through" the interface.
    Think if mouse button is used to select units in a RTS, if I click a "menu" button, I don't want that click to "go though" it and select units below the menu button.
     
  29. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,670
    But some code has to be written, otherwise how would it know when to fire the event you'd added?
     
  30. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,164
    Then, if you make a menu with multiple main buttons and another several sub-buttons... is it going to become a complete huge mess of gameobjects and components in the hierarchy view as using NGUI? :(
     
  31. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    If i not misunderstand you ( im not englishman) then Yeah u are right - there is one question - could we write scripted onclick event fot button when these button have other event onclick in inspector? If yes there isnt any problem we can apply same behaviour for other event if not then it will be harder or impossible - depend on existing system
     
    Last edited: May 29, 2014
  32. Devil_Inside

    Devil_Inside

    Joined:
    Nov 19, 2012
    Posts:
    1,123
    I'd be really happy if at least the main 3 events (click, press, release) would be supported.
     
  33. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,554
    Anonymous delegates perhaps? Like this?


    This is one situation where nested prefabs would be a boon.
     
  34. LuxUnity

    LuxUnity

    Joined:
    Sep 29, 2010
    Posts:
    717
    The new gui look very user friendly and remember me Daikon Forge.

    I hope that basic animations like bump or shake will have some premade parametric element, because made new animation of for every different size button can become time expensive.

    I agree.
     
    Last edited: May 29, 2014
  35. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,489
    This is very refreshing (I've never done UI design before in Unity), and it simplifies the design for most of us. I have a few questions in regards to creating these UI elements.

    1. Will I be able to create these UI elements inside of Photoshop and bring it into Unity?
    2. What are some of the restrictions in creating the elements? Will I have to use a sprite sheet?
    3. How will this handle arrays? Such as life bars or a fight clock...
     
  36. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,670
    That wouldn't help with firing the event. You could potentially hook up an anonymous delegate to be fired, but something somewhere has to do the 'if the button is going from not-pressed to pressed then fire the OnPressed event' logic.
     
  37. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,554
    Sorry, I'm a bit confused. I thought his problem was that sometimes making a callback event you'd end up having to make a class with just that, the callback event. An anonymous delegate would help there perhaps.
     
  38. xCyborg

    xCyborg

    Joined:
    Oct 4, 2010
    Posts:
    634
    Does that mean OnMouseDown and company are finally gone? and the event callback is finally platform agnostic, so no more Input.touches confusing loops, no more touch phases and such? and most importantly no more need for touch suites from the store, that is awesome news.
    I assume it's working for all colliders and not just GUI system, thank you for wonderful news.
     
  39. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,778
    No, all that stuff is still needed for legacy support (though I suppose there's a chance it may get deprecated, if the new event system gets implemented for 3D colliders, though there's no indication that that is the case in 4.6), and Input.touches looping will never go away completely because you frequently need to get more detailed information than simply "I tapped on a button". (For example, the new GUI system cannot and should not handle "pinch to zoom" behavior.)

    Though you'll have to use it all less often, so that should make you happier, anyway.
     
  40. herman111

    herman111

    Joined:
    May 11, 2014
    Posts:
    119
    Will the GUIText and others disappear in 4.6?
     
  41. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,778
    I hope they get deprecated, at least. GUIText and GUITexture are so archaic at this point, and now, finally are actually redundant.
     
  42. RockoDyne

    RockoDyne

    Joined:
    Apr 10, 2014
    Posts:
    2,234
    From the sounds of it, nothing is being deprecated this time round. Whether it will exist in 5.0 is probably a different story. One version should probably be enough time for people to jump ship and get set up with the new system that I can't imagine many people complaining about features being pulled.
     
  43. im

    im

    Joined:
    Jan 17, 2013
    Posts:
    1,408
    ok loved the lastest video

    but is there a video that focuses on c# programming of the new u2 showing the new classes/methods/properties/ect...

    i mean what happens when you press the button. what does the code look like that we would need to create...

    right now we have something like

    Code (csharp):
    1.  
    2. if(GUILayout.Button("Close"))
    3. {
    4.      CloseWindow();
    5. }
    6.  
    please post link to video or tutorial of how 4.6 does it.

    also here are all the controls for existing ui

    http://docs.unity3d.com/Manual/gui-Controls.html
    http://docs.unity3d.com/ScriptReference/GUI.html
    http://docs.unity3d.com/ScriptReference/GUILayout.html

    so what controls do we have in 4.6 and what does their api look like

    please post link to that information (when it becomes available)

    thanks in advance!
    so with 4.6 what would it look like
     
    Last edited: May 29, 2014
  44. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,670
    As far as code when you press a button goes, you can just do:

    Code (csharp):
    1.  
    2. public void StartNewGame()
    3. {
    4.    Application.LoadLevel("level1");
    5. }
    6.  
    and then, in the Inspector, wire up the 'On Click' event of the button to call that function. You don't actually have to mention the button anywhere in code if you're just receiving events from it. You could even do something a little more complex, like:

    Code (csharp):
    1.  
    2. public void StartChapter(string chapterName)
    3. {
    4.   Application.LoadLevel(chapterName);
    5. }
    6.  
    and wire up multiple buttons to call that function but pass different strings in as data.

    Creating or manipulating a button from code is a bit more involved, of course.
     
  45. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    I think he's talking specifically about including the events mentioned earlier that are already fired but not available in the inspector: OnPress, OnRelease, OnHover, etc. Currently if you want to make a button that has an OnPress event in the Inspector you have to subclass Button and write a custom editor. Unity said they only included an inspector UI for "OnClick" because including all the others would make the inspector look cluttered. People are suggesting that instead of requiring coding a custom editor, Unity just adds a "+" button next to OnClick that would let you add an inspector slot for OnPress, OnHover, etc. I agree this would be nice to have. I'm sure it's too late to try and get it into 4.6, but maybe in the future.
     
  46. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    I've seen and read that you can assign custom shaders and materials to the new GUI system and use lighting on UI elements.
    Great stuff - somehow I feel a little p***ed now for buying Daikon Forge UI few weeks ago...
    So I'd like to propose that you work with Joachim to ensure Shader Forge can be set up in a way that creating shaders for the new UI works smoothly.
     
  47. Per

    Per

    Joined:
    Jun 25, 2009
    Posts:
    460
    Can someone give a complete list of the events available? (hoverEnter, hoverExit, button down, button up etc)

    Also are the events themselves extensible, i.e. could you add in new onX events?
     
  48. smx

    smx

    Joined:
    Oct 23, 2013
    Posts:
    10
    I am developing for the Oculus Rift. I see in the video that we can position the GUI in the world, so stereoscopical rendering shouldn't be a problem. I wonder how we can trigger the event easily, though.
     
  49. Lypheus

    Lypheus

    Joined:
    Apr 16, 2010
    Posts:
    664
    Could you not just consolidate your related events into different methods within the same script file?
     
  50. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    I have Daikon Forge and nGUI and I think if they make good money they're learned to enjoy it and will use the new Unity uGUI to extent uGUI since they have a flair for that so the money isn't wasted.

    Most games have too much GUI / HUD fiddling anyway.