Author Topic: Building Material Design UI with NGUI  (Read 29223 times)

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #15 on: October 28, 2014, 04:19:31 AM »
Your ideas are intriguing to me and I would like to subscribe to your newsletter. Pls gief asset store, bac pls. :]

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #16 on: October 28, 2014, 06:11:11 PM »
Hell yeah, everything seems to work right now!



You can now work with any screen density right in the editor, which is especially nice when you have properly prepared all atlases (for 160dpi, 240dpi, 320dpi, 480dpi and 640dpi). I did prepare them, of course - all five atlases, 440 core images each, with proper slicing, resolution, color, atlas scaling, etc. Murdered whole day converting and preparing them from SVG sources by Google. Will probably bundle those resources with the release if it's not prohibited by the license. They are suprisingly lightweight, never topping 1024x1024 atlas size even with insane 640dpi resolution very few devices on the market have. Few things left:

I'd like to add in-editor preview without density clamping - haven't looked into that yet, it's mostly relevant for people with small screens who want to preview ultra-high density layouts that can't fit into Unity window at true scale. Right now, like on targeted devices, density bucket is dropped until you reach minimum allowed screen resolution for a given bucket. I should add an option to allow you to sacrifice in-editor pixel perfect previews to fit high-DPI layouts into your small display (for example, it's impossible to fit 1:1 XXHDPI or XXXHDPI layout onto a 1080p desktop).
« Last Edit: October 28, 2014, 07:42:39 PM by bac9 »

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #17 on: October 29, 2014, 09:11:50 AM »
Had a look at shadows again. I was never fully satisfied with how my dynamic shadows, while fancy, only shifted outward from the widgets and had quite a boring linear gradient, giving them impression of a cheap photoshop effect.



For all the nice look, they weren't really similar to the shadows detailed in guidelines:



So I charted those values into curves, fixed some obviously erroneous values from above that broke those curves, and had a go at rewriting the shadow implementation. Some would say it does not matter, some would say shadows looked alright as they were - sure, maybe. I might leave the old and simple implementation as a low-quality optional mode. But I'm adding a new one, and doubt anyone will want to go back. For a minor performance cost, you get this beauty that completely replicates offline quality you get from layered Photoshop/Illustrator effects. In realtime:



It's driven by three curves (blur, offset, alpha) and an altered post fill method that takes a lot of stuff into account (visibility of the shadow at low radius, separate inward/outward offsets, etc.) and damn it's satisfying to see it work. As always, it's completely automatic: you just add a component to a sliced sprite object and get a slider driving the shadow, and when you remove that component, child sprite it was employing is cleaned up.

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #18 on: October 30, 2014, 11:39:36 AM »
Worked on some refactoring today, so not much to show. But I added one new fancy visual tool: .aco importer! Those files are Photoshop format containing color palettes (swatches) and are widely used to distribute palettes accompanying various design documents. You can download one here, for example: http://www.google.com/design/spec/resources/color-palettes.html

Now you can load one straight into Unity:



You can use it with the standard screen-space color picker from Unity to color your NGUI widgets in a consistent manner. You can also assign those colors to screens, allowing entities controlled by them to automatically use consistent coloration. Pretty neat time saver.


bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #19 on: November 03, 2014, 07:53:37 PM »
After wrestling it for few days, finally got it working. Fancy clipped screen transitions straight out of apps like Google Inbox!


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #20 on: November 04, 2014, 08:27:15 AM »
Keeps getting better and better!

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #21 on: November 05, 2014, 02:27:41 PM »
One particularly inconvenient issue with designing UIs for multiple screen resolutions and densities is how you need radically different proportions and layouts to cover all cases nicely. You don't want lines to span a 4k display horizontally and you don't want your sidebar to eat precious horizontal space on a narrow smartphone screen. So you need to make design responsive.

Uh, well, I solved that, more or less.



I thought about the issue a bit and found a somewhat elegant solution.

  • First, to avoid absolutely horrifying math involved in managing non-overlapping interval lists, I implemented screen resolution intervals through making simple int lists where you define not intervals, but midpoints between them. You can define any amount of midpoints you want - for example, 320px, 480px, 640px, 720px and 1280px in the case of that gif.
  • After that, you can manage a list of layout groups, which contain a GameObject list and two integer sliders allowing you to select the resolution bracket from points you have entered before. Then simple validation logic hides and shows stuff as necessary.

Current implementation looks like this in inspector:



A bit ominous (I can probably get neat color coded interval visualization going for every group), but very easy to use.

Limyc

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #22 on: November 07, 2014, 05:26:23 PM »
This is absolutely incredible. I'll definitely be watching this thread for updates on a release. Maybe a Christmas present?

I almost confused you with /u/Saxy_Man on reddit until I saw him comment on one of your submissions.

r.pedra

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 20
  • Posts: 131
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #23 on: November 24, 2014, 12:09:40 PM »
Simply amazing  :o

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #24 on: December 10, 2014, 03:09:01 PM »
Great news everyone! Responsive layout system progressed very nicely and is pretty different now from object-based draft I showcased above. First, to remind you what responsive layouts are, simple illustration:



There were two biggest issues with the previous implementation:
  • You had to set up the objects in one centralized and unintuitive custom inspector that was disconnected from real UI hierarchy, which is far cry from intuitive and fast anchoring editor every NGUI widget offers you on selection of particular widget within the hierarchy.
  • The implementation used simple enabling/disabling of GameObjects, and you really don't want to deal with that most of the time: imagine having half a dozen of functionally identical data-driven scroll lists instead of one, it's awful.
Both of those issues are out and workflow is much more straightforward now. First, you set up desired resolution brackets. For example, maybe you want to have one layout for screens of below 480dp width, another layout for screens between 480dp and 640dp width, and another layout for screens wider than 640dp. Easy! Just set up your intervals with this neat array in the screen manager (featuring auto-configured clamping to nearest neighbors with fancy sliders and warnings):



Second, add a new component to any UI widget you want to be density dependent. Depending on amount of resolution intervals set up in your screen manager, that component will store appropriate amount of anchoring configurations. The component is not attempting to replace the perfect anchoring editor from NGUI - you still use the familiar controls, except you can save your configuration to one of the resolution brackets. Set up your anchoring for a narrow screen, click the copy button on narrow configuration, set up your anchoring for a wide screen, click the copy button on widescreen configuration. Done.



The screen manager maintains a list of resolution-based anchor components and swaps anchoring configuration to appropriate one depending on detected resolution, giving you results like this while keeping your data-driven UI free from pesky duplicates or other inconveniences. There is no need to set up dozens of resolution-based anchoring configurations either - in some applications, the whole design can be hierarchically anchored to just one widget, necessitating just one collection of configurations on that topmost widget.

Aside from this goodness, I worked on some other stuff like refactoring and new view presenters. One of the new object types is the dropdown menu. While still work in progress, it's already looking quite good:



  • It's using just one label for all the options: no separate labels/colliders/delegates, which conveniently prevents hierarchy clutter and instantiation costs on option list length changes. I get the selection from local touch position.
  • As usual, everything is animated through a simple evaluation: one tweening method with 0-1 float argument does all the magic with sliding offsets, sheets, shadows, spacing, colors, etc. No dozens of tweener instances, no Unity animations, clean and fast.
  • It expands from the list position of a selected value, just like guidelines dictate. Tricky to combine with this animation, but as you can see, it works.
« Last Edit: December 10, 2014, 03:14:37 PM by bac9 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #25 on: December 11, 2014, 08:15:21 AM »
Nice, I was just wondering last night what you ended up doing with the project. Good to see it moving forward!

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #26 on: December 11, 2014, 10:37:53 AM »
I'm just frequently borrowed to do other work, so this project is moving forward slower than I would like. :)

callski

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #27 on: December 15, 2014, 04:18:49 PM »
How close are you to putting something up on the asset store or releasing source? This looks amazing!

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #28 on: December 19, 2014, 07:26:43 AM »
Not earlier than the middle of January I'm afraid, too much is still missing or unfinished.

GHVNlab

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Building Material Design UI with NGUI
« Reply #29 on: December 22, 2014, 11:38:02 PM »
Hi there, your work is amazing. Will u release a pre beta version of this on asset store, a paid beta version. I'm just a MD crazy fan

PS: u should check this out sir http://alexk111.github.io/SVG-Morpheus/