Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

NGUI (Next-Gen UI) -- demo final feedback request

Discussion in 'Assets and Asset Store' started by ArenMook, Dec 8, 2011.

Thread Status:
Not open for further replies.
  1. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Thank you, it's good to hear an opinion of someone who is familiar with other UI kits, especially such a positive one :)

    1) Yup it's done.
    2) You can use UIFont's CalculatePrintedSize() function to calculate the dimensions of the text if it was printed, and WrapText() to split up the text you specify into lines. Knowing the size of the font (the scale) you can multiply it by the number of lines then divide by number of lines per page to figure out how many pages you will need. You can then easily split up the text into several pages by the new line characters.
    3) Same as above, you can split up text beforehand by using UIFont's WrapText function.
    4) That's on the list, but NGUI being 3D makes a bit more of a challenge.
    5) You can create that in seconds in Photoshop or just by using Glyph Designer. It's not dynamic, but it will look much better. :)
    6) Same as #2, CalculatePrintedSize.
    7) UIFont.size. :p
     
    Last edited: Dec 14, 2011
  2. EskemaGames

    EskemaGames

    Joined:
    Jun 23, 2010
    Posts:
    319
    This new update looks awesome :)
     
  3. ChezDoodles

    ChezDoodles

    Joined:
    Sep 13, 2007
    Posts:
    107
    Thanks!

    Most excellent :)


    Tip:
    In UIOrthoCamera, shouldn't you rather compare camera size (height) to Camera.pixelHeight rather than Screen.height - to support camera's that is using just a portion of the screen (Camera.rect viewports)... like two-player split-screens...?
     
  4. ChezDoodles

    ChezDoodles

    Joined:
    Sep 13, 2007
    Posts:
    107
    ...another nice to have feature for speeding up GUI on Android and iPhones:

    GUI windows are often set up using 9-Sliced Sprite's - and you really want the texture to have an alpha channel to support rounded corners and other details. However, putting a big transparent layer (the GUI window) on top of an already complex 3D scene, is a bad idea.

    So...given that the center-piece of the 9-Slice Sprite often don't need to be transparent, it should be nice to automatically draw an opaque rectangle with a pixel-perfect fit to the center-piece of the 9-Slice Sprite - just a few pixels BEHIND. This will add an extra draw call, but will also effectively HIDE all the complex 3D geometry (important for PowerVR chips) while letting the border-pieces of the 9-Slice Sprite utilize the alpha channel for full details (round corners, ornaments, etc).

    This will make sure the NGEN GUI seems very fast and snappy on these devices... cool, eh :)
     
    Last edited: Dec 14, 2011
  5. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    In regards to the UIOrthoCamera tweak you will have to show me what you mean with code.

    The iOS/Android optimization is a valid one, but it's a hardware-specific optimization and is easily enough to do by simply adding a widget using a solid material behind the window, as -- like you said -- it adds a draw call, and would only be practical for large windows. That hidden widget would have a material drawing only to depth, and would be on the same layer as the rest of the scene rather than the UI.

    P.S. Keep in mind 9-sliced sprites are not necessarily solid, and can fade out with alpha.
     
  6. ChezDoodles

    ChezDoodles

    Joined:
    Sep 13, 2007
    Posts:
    107
    Sorry, just me being stupid when porting a lot of code written for another GUI library and having a lot of work-arounds to support short-comings in that library. Don't bother - instead, go back to writing your amazing library. :)
     
  7. SoulWind

    SoulWind

    Joined:
    Aug 25, 2011
    Posts:
    23
    Hello Aren,
    First, thank you for creating this product!
    But I got some problem with depth, I found that if I use two different atlas which use different material, I can't control them with depth.
    like this:
    Button_Start
    └---UILable the font prefab use material A
    └---UISlicedSprite the atlas prefab use material A
    the UILable and UISlicedSprite can arranged by depth very well.
    But if like this:
    └---UILable the font prefab use material A
    └---UISlicedSprite the atlas prefab use material B
    the depth dosen't work...

    So that means I must put all the ui picture and font picture in one png file?
    But unlike English character, I can't put all the chinese character or japanese character in only one png file...
    If I want to make a Multi-language game,the problem will be even worse...
     
  8. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    wow new anchor system is flawless, good job ArenMook! I'm impressed :)

    We could really do with an onHold type event, that constantly calls whilst the button is pressed down, and also some kind of onRelease?
    These things are essential for creating touch screen controls for games.

    EDIT : Okay just realised you get onPress messages when you release aswell with a negative parameter. Great stuff, this is entirely workable :)
     
    Last edited: Dec 14, 2011
  9. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    Eek just hit a pretty hefty roadblock. No multitouch support? Seems to only work with 1 touch :(
     
  10. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    if you are using multiple atlases you have two options:
    1. You can change the transform's Z to bring something forward.
    2. You can use a different shader with one of them (Unlit Transparent Colored Overlay).

    Tell me how you are trying to use it (what you're trying to do) and I will add support for it. :)
     
  11. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    Basically, having a UI of controls on screen... buttons for left, right, forward and back, need to be able to keep track of up to 3 touches independently of each other. If a user wants to press forward and right at the same time it only detects the first touch
     
  12. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Ok, I'll see what I can do.
     
  13. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Ok, it's ready but I can't test it as I don't have access to an iOS device atm. Care to give it a try for me? :)
     
  14. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    absolutely! is it the one on the download page
     
  15. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    No, only one file has changed -- UICamera.cs. I will drop it in the download folder in a sec.
     
  16. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Any luck?
     
  17. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    not seeing any changes in the current package on download page mate
     
  18. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Oh right my bad, the download location is not exposed anymore. Sec, I'll PM you the link.
     
  19. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    yeah man, that works :D, NGUI is really shaping up!
     
  20. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Haha awesome! :D Thanks for testing! I'll update the package for everyone else.

    Edit: PayPal download package has been updated and AssetStore update has been submitted.
     
    Last edited: Dec 14, 2011
  21. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    awesome, just that little issue with reimporting text files if your coordinates are set to texcoords to fix. Then I'll be using it for production :)
     
  22. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Sorry about the delayed response, I was in the process of moving my computer. :)

    You can fix that on your end quickly by going to MiniJSON, line 59 (atlas.sprites.Clear()), and adding a new line right after:

    atlas.coordinates = UIAtlas.Coordinates.Pixels;

    Edit: In any case, updated the package with this line in there.
     
    Last edited: Dec 14, 2011
  23. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    i went back and tried packing my font with my textures by creating a whole new texturepack and it worked fine, for some reason if i choose ascending it puts everything on top of each other making the image very long horizontally, i chose descending and it seemed to squish it back up like it should be and it worked fine for me now lol, your uianchor script is for anchoring things to the screen so they dont move when the screen res is changed right? Like the regular unity GUI system if i put screen.width - (screen.width / 2) - (windowWidth / 2) that would anchor my window directly in the center of the screen and no matter how you changed the size of the screen it was always in the center.
     
  24. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Yup that's right. Docs page on it can be found here, and Example 0 shows its several uses.
     
  25. Bugfoot

    Bugfoot

    Joined:
    Jan 9, 2009
    Posts:
    533
    Not sure if Im doing something wrong, but I noticed that if I update my atlas texture json data (e.g. I add a new sprite to the sheet):
    1) The atlas doesn't update itself automatically
    2) If I manually re-drag the updated atlas json file on the UIAtlas text file field, the atlas is updated correctly BUT it's not saved, meaning that if I restart Unity (even after doing a Save project/save scene combo), the atlas prefab has reverted to the old version (without the new sprite). I've fixed that by calling EditorUtils.SetDirty(mAtlas) in the custom inspector for the UIAtlas.

    If you save a reference to the sprite json text file, it should be easy enough to detect when it has changed and automatically reimport the atlas data without manual user input.

    Other than that, I'm really liking this package so far - it's been so much easier to use than the other much more pricey UI packages available. The KISS principle in action, I suppose! :)
     
  26. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    1) This is intentional. Import is a one-time thing. There is no reference to the file once you import the data (allowing you to delete it safely).
    2) That's how Unity works with prefabs. I've noticed that before. Before modifying your atlas's data, drag it into the scene. You can then modify it and hit Apply. If you're saying that marking it as dirty fixes the issue then I will add that line in there, thanks. :)
     
  27. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Quick Question, is there a way to stop this from happening? (this is a UIInput):

     
  28. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Yup, latest version allows you to specify maximum length of the text field in pixels.
     
  29. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    For my next question, how about password fields?
     
  30. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    I can add a feature for that in the morning. :)
     
  31. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    Hey ArenMook, I'm having the same issue as Spk with shutting down Unity and reopening, all my atlas information has gone and I have to reimport the txt file again. I would prefer if it did save somehow, it's not a huge issue just a minor annoyance :) What's more of an issue is the loss of my inner rectangle settings each time I update
     
    Last edited: Dec 15, 2011
  32. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    Another suggestion I've implemented on my copy, but would be good to see in the official build,
    Having the gizmos to move UI stuff around is really useful but a 2D Ui often gets in the way of your actual scene as its big (pixel sizes) compared to game stuff, and the gizmos steal your mouse focus when trying to edit scenes. So perhaps a Selectable toggle on UIPanel that stops the gizmos being drawn if it is off.
     
  33. EskemaGames

    EskemaGames

    Joined:
    Jun 23, 2010
    Posts:
    319
    Saving the inner rectangles will be more complicated, because the atlas from texture packer will change a lot, and you have to check string by string if the image was available before and if so, check the inner rectangles to not overwrite them.
    Not an easy feature...
     
  34. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Thanks Eskema. :) Yes it's true, it's not an easy feature because rectangles can change drastically on import. And not just move around -- they can be rotated as well and all of this has to be taken into account somehow. I'll just have to figure out an elegant solution for it...

    Edit: Done.

    In the meantime version 1.09 is ready:
    • Added support for password fields (specified on the label)
    • Fix for fonts and atlases not keeping their data if working directly with prefabs without bringing them into the scene
    • Showing gizmos is now an option on the panel
    • Sprite inner rects will now be preserved on re-import
     
    Last edited: Dec 15, 2011
  35. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    I've updated version 1.09 to support preserving inner rects on import.
     
  36. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    This is great :) thanks again
     
  37. BrUnO-XaVIeR

    BrUnO-XaVIeR

    Joined:
    Dec 6, 2010
    Posts:
    1,687
    This tool is a very well done and smart system. Some procedures could be automatic though, but I may consider give it a try in the future.
     
  38. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    set the scale of your ui object that parents the interfaces down. i usually use 0.25 or 0.025 and leave the other scales alone(allows you to use real pixels because your parent object is scaled down not the other objects :))
     
  39. mydingefnysen

    mydingefnysen

    Joined:
    Dec 15, 2011
    Posts:
    51
    Looks like you are doing a great job on this! Im really interested in getting it but would like to ask some questions first.

    1. Is this well suited for for example icons floating around in the 3D world together with other geometry? I mean, can my normal fps-cam be used as a gui cam as well or does it has to be parented to a panel object?

    2. We need everything to be set up by code (defining the gui in xml, loading the texture atlases from online sources and so on), any problems with that?

    3. At the moment we use UniTUIO quite a lot (the multi-touch TUIO solution for unity), so I guess that needs to be modded in somehow. How is the multi-touch implemented right now? Would it be easy to add pinch-zoom to a sprite for example?

    Thanks!
     
  40. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    1) Your main camera can also be used to draw UI, no problem. In case of a 3D game this allows you to create dynamic in-game geometry, such as signs, floating text, name tags, icon indicators, and more. Furthermore, the UI doesn't need to be one draw call. You can create many signs for example, and each one can be its own draw call, culled automatically by Unity if it's not visible. A panel is simply a separator -- every widget that's a child of the panel will be drawn by that panel. That's all.

    2) All properties have been set up to make this a trivial task.

    3) Each touch is handled independently. If you press on an object, it gets OnPress. If you press on it with another finger, you get another OnPress, and each one will be sending OnDrag events independently as well. If desired you can tweak a single class (UICamera) to have it pass touch ID along with mouse touch events for additional functionality. All that you'd have to do is simply add an extra parameter to the SendMessage calls inside the update. :)
     
  41. SoulWind

    SoulWind

    Joined:
    Aug 25, 2011
    Posts:
    23
    hi ArenMook
    After I updated NGUI from 1.06 to 1.09 I found that all the UI didn't clean when disable it...
     
  42. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    I've been working with 1.09 all day and haven't noticed this. In fact just tried and everything seems as expected. Disable a game object -- UI disappears. Disable the script -- again UI disappears. Do you mean something else by "didn't clean"?
     
  43. SoulWind

    SoulWind

    Joined:
    Aug 25, 2011
    Posts:
    23
    I mean when I disable a game object(code: Window_XXX.active = false;) with NGUI the UI still there(but can't select just like a picture)
    But if I enable or disable this object in inspector window, the UI show/hide correct...
    It's there some wrong with my code?
     
  44. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    'active' is a deprecated function in Unity. You shouldn't be using it. Try 'enabled' instead.
     
  45. SoulWind

    SoulWind

    Joined:
    Aug 25, 2011
    Posts:
    23
  46. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    "enabled" is on scripts, "active" is on the game object. Component.active is the one that has been deprecated. Are you doing this during play or edit mode? If during edit, try adding a EditorUtility.SetDirty(gameObject);
     
  47. SoulWind

    SoulWind

    Joined:
    Aug 25, 2011
    Posts:
    23
    Maybe I have wrong expression...
    What am I doing is on the gameobject not the component...
    And doing this during play mode
    or could you tell me how to "close a window" by code?
     
  48. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    You're absolutely right. I just tested it on my end. I'm uploading a fix now, but if you have a version from the asset store, you can fix it quickly yourself by adding this line:

    if (!w.enabled || !w.gameObject.active) continue;

    ...right below line 194 in UIPanel.cs. That's this line:

    if (w.material != mat || w.color.a < 0.001f) continue;

    Thanks for the report!
     
  49. SoulWind

    SoulWind

    Joined:
    Aug 25, 2011
    Posts:
    23
    I have the version from your website:)
    thinks for the quick fixed!
     
  50. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Anytime. :)
     
Thread Status:
Not open for further replies.