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
    Very nice! My suggestion though -- do something about the text. You should have RGB set to pure white for text to be clear. Only alpha should have the grayscale lettering.
     
  2. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Parts of the texture? Can you elaborate on the process steps?
     
  3. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    Nowhere near as crisp as the Scaleform version. Perhaps NGUI could optionally plugin to RageSpline and use vector stuff!
     
  4. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Two reasons for that -- the font must have white in RGB instead of black white, and some bloom on top to make it fancier.
     
  5. nab477

    nab477

    Joined:
    Jun 14, 2011
    Posts:
    46
    Hi, I'm interested in buying NGui for both my current project as a part of my essential tools for the future projects.
    but, I'd like to ask a few things first.

    can I put up a Health HUD or loading gauge using NGui ?
    (basically like the audio slider, but filled by code doesn't have the actualy slider, but it may be filled with custom images instead of solid color)

    what effects/properties can I give the text ? (shadow, gradient ...etc)

    you mentioned support for eastern languages, does that include support for right-to-left support ?
    (obviously aligning right is there, but I meant in some languages (e.g. Arabic) the text actually has to be flipped in order to be displayed properly)
     
  6. Asse83

    Asse83

    Joined:
    Aug 1, 2009
    Posts:
    169
    I think this happens when the atlas texture gets bigger than 1024x1024, maybe you want to try it on your own.
     
  7. Asse83

    Asse83

    Joined:
    Aug 1, 2009
    Posts:
    169
    Also I noticed that the OnRelease function with buttons doesn't work as expected. Normally the OnRelease callback doesn't get called when you're not above the item on release. In NGUI, the callback is called anyway.
     
  8. WolfGames

    WolfGames

    Joined:
    Jul 25, 2011
    Posts:
    65
    yes i wanna too text effects.. glow, blur shadows.. etc.
     
  9. cjow

    cjow

    Joined:
    Feb 29, 2012
    Posts:
    132
    I've heard that NGUI is not compatible with SpriteManager2 because of conflicting editor classes among other things.

    Is this true? If so is there a way around it?
     
  10. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    @nab477: Health HUD, loading gauges -- of course:

    http://www.tasharen.com/?topic=creating-a-ui-sprite-on-the-fly

    Currently built-in effects for text include a shadow (or bevel), and outline. You can do fancier effects with shaders if you're so inclined.

    Right-to-left support is not immediately supported by input, but you can tweak the UIInput a little to add support for it (basically instead of appending new characters to the right, append them to the left instead).

    @Asse: Instead of OnRelease, consider using OnClick.
     
  11. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    NGUI is not compatible with EZGUI or SpriteManager, but you can make it compatible by renaming conflicting class names.
     
  12. Asse83

    Asse83

    Joined:
    Aug 1, 2009
    Posts:
    169
    No no, I want to use OnRelease, but as I said, the behavior differes from what you know from other GUIs of applications/operating systems like Windows, iOS and so on. When you release the press/click and you're not above the item, it shouldn't trigger the OnRelease method.
     
  13. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    If you want that kind of behaviour, change UIButtonMessage OnPress function from:

    Code (csharp):
    1. void OnPress (bool isPressed)
    2. {
    3.     if (((isPressed  trigger == Trigger.OnPress) ||
    4.         (!isPressed  trigger == Trigger.OnRelease))) Send();
    5. }
    To:

    Code (csharp):
    1. void OnPress (bool isPressed)
    2. {
    3.     if (((isPressed  trigger == Trigger.OnPress) ||
    4.         (!isPressed  trigger == Trigger.OnRelease  UICamera.lastHit.collider == collider))) Send();
    5. }
     
  14. kaushik-d

    kaushik-d

    Joined:
    Aug 25, 2011
    Posts:
    19
    I'm trying to build a tree like control using NGUI to show hierarchical data. I've got a simple tree view using nested UIGrid's but have to manually insert blank items (underneath parent tree nodes) to show tree indentation. What could be the best possible approach in NGUI to make such a control?
     
  15. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Best approach? Create a custom widget. It may not be necessarily the fastest, however. You can also write your own placement class instead of the grid / table. That would be faster.
     
  16. ArcDragon

    ArcDragon

    Joined:
    Feb 21, 2012
    Posts:
    23
    Hi.
    How to change the UILabel alpha In script?
    My code can't works.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class NewBehaviourScript : MonoBehaviour {
    6.     private UILabel label;
    7.     // Use this for initialization
    8.     void Start () {
    9.         label = GameObject.Find("Label").GetComponent<UILabel>();
    10.     }
    11.    
    12.     // Update is called once per frame
    13.     void Update () {
    14.         label.color.a = 0.5f;
    15.     }
    16. }
    17.  
    Where is alpha ?
     
  17. mohydineName

    mohydineName

    Joined:
    Aug 30, 2009
    Posts:
    301
    Hi,

    I d like to make a feature request:
    I d like to have a new Clipping option for the UIGrid:
    -When any of the child of an item in the UIGrid is not visible, then make the whole item not visible.

    This way I could certainly avoid using the slow OpenGL ES 2.0.

    Please let me know if that is ok.

    Stephane
     
  18. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    @ArcDragon:
    You shouldn't use GameObject.Find. It's slow, and hard-coding names is a very bad practice. Attach this script directly to the label instead, or have a public reference to your label that you will set in the inspector.
    Try attaching this script to your label:

    Code (csharp):
    1. using UnityEngine;
    2.  
    3. [RequireComponent(typeof(UILabel))]
    4. public class NewBehaviourScript : MonoBehaviour
    5. {
    6.     UILabel mLabel;
    7.  
    8.     void Start ()
    9.     {
    10.         mLabel = GetComponent<UILabel>();
    11.     }
    12.  
    13.     void Update ()
    14.     {
    15.         Color c = mLabel.color;
    16.         c.a = 0.5f;
    17.         mLabel.color = c;
    18.     }
    19. }
    @mohydine: Clipping is done entirely via shaders right now. You can certainly write a different class to do the kind of clipping you're describing, and it would be pretty easy to do -- simply store the rectangles of each of the child of the new grid (NGUIMath.CalculateRelativeWidgetBounds), then check them against some rectangle specified in your script.
     
  19. ArcDragon

    ArcDragon

    Joined:
    Feb 21, 2012
    Posts:
    23
    @ArenMook
    Thank you for your tip!
    You've been very helpful!
     
  20. Art Of Bytes

    Art Of Bytes

    Joined:
    Jun 8, 2011
    Posts:
    198
  21. ArcDragon

    ArcDragon

    Joined:
    Feb 21, 2012
    Posts:
    23
    Hi.
    Excuse me.
    I want to question again.

    I use progress bar.
    Bar works in unity project.
    but,progress bar don't works in web player,after I build game.

    This is my code,which is attached to progress bar object.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class NewBehaviourScript : MonoBehaviour {
    6.     private UISlider slider;
    7.  
    8.     void Start () {
    9.         slider = GetComponent<UISlider>();
    10.     }
    11.  
    12.     void Update () {
    13.         slider.rawValue = slider.rawValue * 0.9f;
    14.     }
    15. }
    16.  
    Why?
     
  22. Peter Hou

    Peter Hou

    Joined:
    Oct 12, 2010
    Posts:
    66
    Hi,

    I was wondering what kind of text formatting is possible with NGUI? Are we just able to change the colour or can we do other things as well?

    I'm currently working on a project that requires a lot of text formatting - pretty much anything you can do with HTML would be nice, but I know that's asking a lot :D

    The two primary features I would need are proper bullets with indentation:

    • Item 1
    • Item 2
    • Item 3

    And being able to specify a hyperlink in the text.

    Do you have any plans for more text formatting?
    Thanks for your time - the plugin looks great :)
     
  23. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,203
    you need to use slider.sliderValue instead of rawValue. rawValue is only for use in the editor.
     
  24. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    I currently have no plans to add support for hyperlinks in text. A skilled dev could add support for that within a few days, but it would complicate the system too much for me to add it to NGUI myself. I want to keep it simple to make it easier for others to modify it to suit their needs.
     
  25. bitomule

    bitomule

    Joined:
    Oct 27, 2008
    Posts:
    173
    Does NGUI offers an easy system to create menus for different screens resolutions like iPhone3G or iPhone4. iPad or iPad retina..

    Thanks!
     
  26. ArcDragon

    ArcDragon

    Joined:
    Feb 21, 2012
    Posts:
    23
    @Jaimi
    Thank you very much!
    It works!
     
  27. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Yes, there are a few tools for that. You can choose your layout to scale with the resolution, or stay pixel-perfect as the dimensions change. UIAnchor lets you glue widgets to sides or corners of the screen. UIAtlas and UIFont have a 'replacement' parameter, letting you swap SD for HD atlas... and a few other tricks.
     
  28. bitomule

    bitomule

    Joined:
    Oct 27, 2008
    Posts:
    173
    Thanks @ArenMook, that's all I need to know to purchase it!
     
  29. rezilausiv

    rezilausiv

    Joined:
    Nov 18, 2010
    Posts:
    126
    Hi

    And whats about changing cursor pointer by rollover a button?
    I mean, this is the very common way to show the user, what's interactive and what not..
     
  30. ArcDragon

    ArcDragon

    Joined:
    Feb 21, 2012
    Posts:
    23
    Hi.
    I'm sorry to bother you again.

    I have a health bar question in the NGUI.
    How can I set health bar above game object?

    I read this topic.

    http://www.tasharen.com/?topic=creating-a-ui-sprite-on-the-fly

    With reference to this topic, I tried to make.but my project don't works...
    What should I do?

    my project construction
    Hierarchy
    Cube(AddUnitHUD is attached),MainCamera,Ground

    Project
    Anchor,AddUnitHUD,UnitHUD,NGUI

    Anchor
    -Panel(UnitHUD is attached)
    --Label
    --Progress Bar

    Thank you.
     
    Last edited: Mar 18, 2012
  31. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Assuming you create the cursor, just have that script watch UICamera.hoveredObject, and change the icon accordingly.

    @ArcDragon: You need to use 2 cameras. One for your game (main camera), and one for your UI (2D camera).
     
  32. ArcDragon

    ArcDragon

    Joined:
    Feb 21, 2012
    Posts:
    23
    @ArenMook
    Thank you for your reply.Hmm...I tried to create camera.
    However, My project isn't working...

    current picture


    current game screen


    What went wrong?
     
  33. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    I see 1.84 does not solve this issue, when will u plan to look at it ?
     
  34. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    @ArcDragon: http://www.tasharen.com/ngui/gt.unitypackage

    @yuewah: I haven't figured out an elegant way of addressing this yet. As I mentioned, the widget would need to double in size to compensate. Ie: if it was 200x100 before, it will need to be 400x200. If you have a suggestion, please let me know.
     
  35. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    so disappointed to hear about that, btw, if I can set the border width ( line 109 - 112 ), then it may solve my problem.
     
    Last edited: Mar 19, 2012
  36. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Well, the problem comes from the fact that the resolution changes, going from SD to HD, thus doubling in width and height... but the sliced sprite does not change -- it remains the same size. Since the atlas also gets changed to a HD version, the border width gets doubled. Since widget size didn't change, now you have a visibly thicker border. To compensate, you need to scale your widget to match the resolution change. That's the not-so-elegant solution.
     
  37. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    UIAtlas.cs
    Code (csharp):
    1. public class Sprite
    2. {
    3.     public float borderScale = 1;
    UISlicedSprite.cs
    Code (csharp):
    1.  
    2. //Vector2 tl = new Vector2(borderLeft / 2 / sz.x, borderTop / 2 / sz.y);
    3. //Vector2 br = new Vector2(borderRight / 2 / sz.x, borderBottom / 2 / sz.y);
    4.            
    5. Vector2 tl = new Vector2(borderLeft * this.mSprite.borderScale / sz.x, borderTop * this.mSprite.borderScale / sz.y);
    6. Vector2 br = new Vector2(borderRight * this.mSprite.borderScale / sz.x, borderBottom * this.mSprite.borderScale / sz.y);
    And then, in Altas Inspector, set borderScale = 0.5 in UI-hd and borderScale = 1 in UI-sd.

    It solved my problem, but property name ( borderScale ) is not good at all.
     
  38. KvanteTore

    KvanteTore

    Joined:
    Feb 16, 2010
    Posts:
    87
    What if UISlicedSprite could automatically keep its borders in pixel perfect size regardless of parent objects' scale?
     
  39. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    It does, that's why yuewah is having issues. The atlas becomes higher res, but the sprite remains the same size on the screen. Since the border is now thicker, it's now taking more space on the screen -- more of the fixed size of the sprite.
     
  40. KvanteTore

    KvanteTore

    Joined:
    Feb 16, 2010
    Posts:
    87
    Sorry, I'm not expressing myself properly. The sprite border size doesn't take into account the scale of parenting objects when trying to keep the border pixel perfect on screen; if UIRoot or Panel or any of the other parenting objects scale, the sprite borders scale as well.

    I'm not sure how you're intending the use of atlas replacement for HD GUIs, and if you have a good solution, I'd love to hear it. Currently, the way I'm doing it is by disabling the auto scale in the UIRoot component, so that the UI scales with the screen resolution, and then set the replacement atlas when the screen is twice as large as the original size.

    Using this method, I end up with the same problem as @yuewah, because the scale of UIRoot keeps the sprite in the same screen space rect as before, but with twice as large borders. If UISlicedSprite could keep it's borders in pixel perfect size regardless of UIRoot and Panel scales this would not be the case. It would be similar to @yuewah's solution, but setting borderScale relative to transform.lossyScale

    I'm not sure how this would work on 3D UIs though, and there would probably have to be some kind of messaging to recalculate the mesh when parent objects scale.
     
  41. ArcDragon

    ArcDragon

    Joined:
    Feb 21, 2012
    Posts:
    23
    @ArenMook
    Thank you!
    I'd really appreciate it!
     
  42. mohydineName

    mohydineName

    Joined:
    Aug 30, 2009
    Posts:
    301
    OK. What is the proper way to make en item NOT visible? UIWidget.visibleFlag to 0 is not enough is it?
     
  43. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Just set widget.enabled = false.
     
  44. helioxfilm

    helioxfilm

    Joined:
    Apr 23, 2008
    Posts:
    259
    Is this solution working in that case when I enable a panel from its disabled state, but some widget are in this widget.enable = false state? Maybe you remember my multiple panel solution from earlier, when each row had three different set of widget, but only one should be enabled, not all.
     
  45. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    I'm not sure if this is what you're referring to or not, but SetActiveRecursively logic won't enable/disable individual scripts (as it changes the active state of game objects, not enabled state of scripts).
     
  46. helioxfilm

    helioxfilm

    Joined:
    Apr 23, 2008
    Posts:
    259
    But when I set to active, and a widget is in this false state, then will it be visible or not?
     
  47. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Nope, it won't be. Game object's active state and script's enabled state are different.
     
  48. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Speaking of enabling and disabling:

    I've had cases where colliders would still trigger even though a panel is disabled. I've worked around it by disabling and enabling colliders explicitly along with the panels. I haven't double checked my code, so it could be something weird I'm doing on my end, but is this intended behavior?
     
  49. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    If you disabled the panel by doing panel.enabled = false, then all the children game objects are still active and so are their colliders. They're simply not visible due to the panel being hidden. If you disabled them via SetActiveRecursively, then it should work fine. From what I hear though, SetActiveRecursively behaves oddly in some situations though. I'm going to write my own function to enable/disable things properly.
     
  50. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Sounds awesome - I would love to be able to disable all colliders underneath a panel - I considered making a convenience method just for that, but it would be nice to have it within NGUI (that way, you could probably cache all of those colliders, too).

    SetActiveRecursively has some issues, and can also be pretty slow on mobile as well - i'd love to avoid it if possible.
     
Thread Status:
Not open for further replies.