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
    What value are you changing? Is Unity even able to read properties? If you're modifying the internal MColor directly, it won't work. You have to do it via the widget's property 'color'.
     
  2. SoulWind

    SoulWind

    Joined:
    Aug 25, 2011
    Posts:
    23
    so untiy's animation system can only show MColor....
    ex2D have this problem at first, then the author add a AnimationHelper to let it work with AnimationSystem
     
  3. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Here's a helper class that will do just that:

    Code (csharp):
    1. public class UIColorAnimationHelper : MonoBehaviour
    2. {
    3.     public UIWidget target;
    4.     public Color color = Color.white;
    5.  
    6.     void Update ()
    7.     {
    8.         if (target != null) target.color = color;
    9.     }
    10. }
     
  4. SoulWind

    SoulWind

    Joined:
    Aug 25, 2011
    Posts:
    23
    thanks~
    maybe you can add this into the package:)
     
  5. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    Hey ArenMook I don't suppose you've had much chance to test this with the flash exported in the public beta? It was all going really well till I added a slightly complex UI for a computer screen that had multiple sprites, sliced sprites and the like. And things just randomly don't appear, I've tried checking depths so everything is on its own depth, and using shader vs. not using shader, and same problems throughout. I know the flash exporter is only beta at the moment but just curious if you'd had anything like this happen for you?

    Cheers!
     
  6. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    Some more information on the flash exporter problem
    It only seems to take effect when the scene is changed and the new scene has a seperate UI object with a new uipanel
    It's fine within editor but in flash player it doesn't show anything off my UIAtlas, UILabels work and the fonts are fine.
    I tried adding the atlas object to the scene and making the sprites use that reference instead of the prefab in my project directory and its working now. No idea why, but it's a workaround for now
     
  7. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    I've also had problems with things randomly disappearing if they were not contained within the same uipanel, having nested uipanel objects and scripts seemed to cause sorting problems, and then eventually objects just not appearing, this in the editor though.
     
  8. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    If you are using multiple UIPanels, then you need to make sure that they have a different Z value in the transform's position, or they will be z-fighting (also known as appearing/disappearing as they move). Simply put: unless Z is different, Unity won't know which one is supposed to be in front.

    'Depth' field is only for sorting widgets in of the same panel.
     
  9. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Last edited: Dec 31, 2011
  10. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Really nice Aren :D!!!

    Question:
    UIState positions, rotation, growonhover... those animations with update() are really expensive in flash, itween is not compatible :(, i will try with couroutines or invoke, anyone knows another option?
     
  11. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    iTween is not flash compatible? That's unfortunate.

    If you want better performance in flash, change the animation speed to a high number, such as 1000. This will make transitions instant rather than smooth, but it will also mean that UI won't be changed every frame, resulting in perfectly smooth performance in flash.

    I can also create a bunch of alternative animation scripts, from-to over time kind of stuff... if it will help and it's a feature people want.
     
  12. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Yes already tried that it works fine but i want smooth animations xD... overlay with ui made on flash its less expensive :(

    Well let me know if you made that script :)
     
  13. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
  14. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    Really cool!
     
  15. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    327
    Are you going to make a tutorial on your site for how you built the ScrollView scene?
     
  16. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Do you mean example 2? You can pretty much examine the scene and see what I did there, I think it's fairly straightforward. I can create a writeup for it later if it's needed, bust most of what's there is handled automatically via NGUI's scripts. As long as your scene has the same structure and uses the same scripts, you will achieve the same result regardless of what you place in the scroll view.
     
  17. profanicus

    profanicus

    Joined:
    Nov 23, 2009
    Posts:
    295
    A small editor-only usability request, if at all feasible:
    can you make UIAnchor update itself whenever the aspect ratio of the Game window is changed? At the moment you have to click an anchored object to force them to all update. It is no big deal, only a minor thing.
     
  18. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    I remember looking into this a couple of weeks ago and it seemed that Unity simply doesn't send out an Update event when the aspect ratio changes. Without an update event there is nothing I can do. :(
     
  19. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    327
    Cool, I'll look at that sample.

    A few minor things I think might help the package.

    * Prefabs for widgets or basic interfaces. So, include prefabs for buttons, text labels etc. that already have the scripts and objects attached to them. So you can just drag out prefabs into a scene and then modify them. I mean yeah I can make my own, but I figure for new users to the package it would make things much quicker.

    * Automatically add box colliders. I think that it would be better if you could just toggle a 'clickable' checkbox on a component's script and have it add/remove the box collider instead of using the menu option.

    Anyway--great work!
     
  20. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Keep in mind, the event system is not limited to the UI. Anything with a collider can receive events. Furthermore, when you set up buttons, you typically create them like so:

    Game Object "Button"
    - Child UISlicedSprite
    - Child UILabel

    The collider goes onto the "Button" game object, which is not a widget, so there is nothing to add "clickable" checkbox to.

    As for prefabs, that might be useful, thank you. The only tricky thing about it I see is prefabs would be for the example atlases. Most people who use NGUI will be creating their own atlases rather than using the provided ones, rendering prefabs kind of useless.
     
  21. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    327
    Not really though, just changing the atlas is easier than setting the whole object up. Or perhaps you can have a menu option to set the atlas globally for the scene so that any prefab you drag into the scene uses that atlas by default.

    3-4 steps to make a button may not sound like much, but add up all the buttons you have to make in a game and a set of prefabs will save a lot of time (and potential bugs)
     
  22. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Keep in mind you can simply copy/paste buttons. Set up one, copy/paste the rest.
     
  23. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    1.20 is now available for everyone who grabbed it via PayPal, and should be up on the Asset Store shortly.
     
  24. ranilian

    ranilian

    Joined:
    Dec 24, 2011
    Posts:
    45
    Hey Aren,

    Good job on this product!

    I noticed that whenever you create a UILabel the Gizmo Rectangle does not update with the text size. It makes it kind of hard to select the text since only part of it is selectable.

    Not a big deal though, but just a simple issue. =)

    Thanks,
    Rani
     
  25. ctsteve123

    ctsteve123

    Joined:
    Sep 13, 2007
    Posts:
    51
    I have purchased NGUI and am having fun using it. The character example Orc was one of the reasons for purchasing, since it is so unique.

    It would be helpful to have perhaps a detailed tutorial/video on how this was created with explanations.

    Also if you get a chance more examples using the database.

    Keep up the great work.
     
  26. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    @ranilian: I plan on looking into it in the near future. I just wish I could rotate gizmos, but Unity currently doesn't support that. :|

    @ctsteve123: Yeah that scene can certainly use some more documentation. I'll put it on the list.
     
  27. ZachGriffin

    ZachGriffin

    Joined:
    Apr 1, 2010
    Posts:
    49
    Hi Aren,

    Is there any in-built functionality for dealing with different resolutions when using an orthographic camera? i.e a HUD scenario where you can specify the bounds of the viewport and have it scale for different resolution ratios without losing the layout...
     
  28. Quickfingers

    Quickfingers

    Joined:
    Aug 29, 2009
    Posts:
    268
    check out Gizmos.matrix for rotations
     
  29. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    @ZachGriffin: Example 0 shows how to keep the UI elements you create the same pixel size regardless of resolution. Other than that, by default UI will scale itself accordingly as the resolution changes (depends on the height of the window, maintaining the aspect ratio).

    @quickfingers: Thanks for the tip, I'll take a look at it.
     
  30. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    @quickfingers: Lol I'm surprised no one mentioned that before! I had no idea that was there. Time for v1.21...
     
  31. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Fixed in v 1.21. Thanks again, quickfingers! :D

    Edit: Btw, someone was asking to be able to read release notes without having to download the package... Here's the link.
     
    Last edited: Jan 2, 2012
  32. hjupter

    hjupter

    Joined:
    Dec 23, 2011
    Posts:
    628
    Great updates!!

    Hey UICursor its really slow on flash it drops about 15-25fps when dragging/moving an icon do you know any way to work around this?

    This happens when have a game scene behind
     
    Last edited: Jan 2, 2012
  33. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    I noticed flash seems to really hate it when the meshes get changed, such as when something is moved or resized. You could think creatively around this issue and instead of moving the widget, have the widget be stationary somewhere off-screen, and have another camera actually draw it and move around, making it look like it's moving. Other than that, you can also try putting the cursor on a different UIPanel and see if that helps, but I have a feeling the problem is with Flash/Unity here, and the best way to go would be to limit the amount of changing content in order to achieve good performance.
     
  34. ranilian

    ranilian

    Joined:
    Dec 24, 2011
    Posts:
    45
    Thanks Aren for the update!

    I was also wondering how to anchor a widget relative to itself. For example, setting the anchor to left on a UIButton would left align the UIButton and so on. Same goes for text and such. I can see that you have the centered option for UILabels but can that be changed to support all sides? Top Left, Top, Top Right, Center, ... etc.

    By doing it this way, we would be able to easily place UIWidgets on any side of the screen (including the center) without any modifications to the transform.
     
    Last edited: Jan 2, 2012
  35. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Right/bottom text alignment is already on the list, I should have it in soon. As for alignment relative to itself as far as UIButtons are concerned? I am not quite sure what you mean there. You can always UIAnchor a game object, then add a child to it that has been offset by the width of the button to make it be anchored however you like.
     
  36. ZachGriffin

    ZachGriffin

    Joined:
    Apr 1, 2010
    Posts:
    49
    Thanks Aren! I bought it this afternoon and I'm really impressed with it. Very slick, much better than your competition and quite intuitive as well. That said, one feature which would greatly improve the functionality is the ability to use delegates alongside the messaging system that's implemented at the moment. It appears currently (correct me if I'm wrong) that a send state script is required for each additional target and that only sends the message to the game object without explicitly defining the message sender.

    In the case of a more complex UI i.e A main menu system with different panels and a state machine to control the user flow; this gets quite messy with a new receiver script required for each button. It would be a much cleaner approach to have a delegate inside the send state script that defines the objects state i.e.(click, drag, etc) so all of a panel's UI elements could be controlled via a single class.
     
  37. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    SendState series of scripts are just examples of how the messaging system can be used. You can implement your own scripts -- and I would advise you do, like so:

    Code (csharp):
    1. public class MyCustomListener : MonoBehaviour
    2. {
    3.     void OnClick ()
    4.     {
    5.         Debug.Log("Clicked, do your logic here");
    6.     }
    7. }
     
  38. ChezDoodles

    ChezDoodles

    Joined:
    Sep 13, 2007
    Posts:
    107
    UISlicedSprite

    Would love to see a variation of the UISlicedSprite component, which would only draw the center piece. Sometimes, I would like to re-use the center piece as backgrounds without the fancy borders - without having include TWO copies in the texture-atlas.
     
  39. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    The less stuff there is in the package, the shorter the learning curve. It's easy to create an extra sprite giving it the dimensions of your sliced sprite's inner rect to achieve this effect, so it doesn't make sense to create a new widget just for this purpose.
     
  40. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Don't get me wrong, I'd love to implment every feature request I get -- but that's a quick way to get the kit bloated and unwieldy -- something I don't think anyone wants. :)

    On a brighter note, 1.22 has been uploaded:
     
  41. ranilian

    ranilian

    Joined:
    Dec 24, 2011
    Posts:
    45
    I think we are talking about two different meanings of anchor. What I'm trying to say is, we should be able to specify a pivot point on the UIWidget where the position will be placed at. For example, if the UIWidget has a TopRight Anchor point, it's position would be at this point, allowing us to basically show all of the widget at the TopRight position assuming that we have a UIAnchor script pointing to TopRight also; Currently it would either place the TopLeft Point of a Widget at this location or (if centered was selected) it's center point.
     
    Last edited: Jan 2, 2012
  42. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Gocha. Can do. I'll add it to the list.
     
  43. ranilian

    ranilian

    Joined:
    Dec 24, 2011
    Posts:
    45
    Thanks!

    Another question, I'm not sure you can answer this but here it goes. I know that to pause a game we can set Time.timeScale to 0, however, I've noticed that when I do that, I can't seem to get any click results on the widgets anymore. Do you have any clue why it would do that?
     
  44. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    That would be because FixedUpdate doesn't get called while timeScale is 0, and that's where the raycast into the screen occurs. You can fix it on your end by opening up the UICamera class, navigating down to around line 295 where you see:

    Code (csharp):
    1.  
    2. bool pressed = Input.GetMouseButtonDown(0);
    3. bool unpressed = Input.GetMouseButtonUp(0);
    And adding this line:

    Code (csharp):
    1. if (Time.timeScale == 0f) mMouse.current = Raycast(Input.mousePosition, ref lastHit) ? lastHit.collider.gameObject : null;
     
  45. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
  46. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    This is now in 1.23: The 'centered' property on widgets has been replaced with a new 'Pivot' property giving you freedom to align widgets to all 4 corners, 4 sides, and center.
     
  47. ranilian

    ranilian

    Joined:
    Dec 24, 2011
    Posts:
    45
    Wow awesome!

    Great job!

    Thanks!
     
  48. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    Just wanted to share this, I played around with the code that Neodrop wrote a bit ago, and got NGUI sending events to universe's graphs, just add this component to the objects that receive ngui events, put a universe graph on these objects, and use the advanced message manager to receive the events.


    Code (csharp):
    1. using UnityEngine;
    2. using Antares.Vizio.Runtime;
    3.  
    4. public class CustomListener : MonoBehaviour
    5. {
    6.         void OnClick()
    7.         {
    8.                 Debug.Log("I was clicked on!");
    9.                 MessageManager.SendMsg(this,"OnClick", "Called from NGUI !");
    10.         }
    11.        
    12.         void OnHover(bool val)
    13.         {
    14.                 Debug.Log("I was " + (val ? "hovered on" : "not hovered on"));
    15.                 MessageManager.SendMsg(this,"OnHover", val);
    16.         }
    17.        
    18.         void OnPress (bool val)
    19.         {
    20.                 Debug.Log("I was pressed");
    21.                 MessageManager.SendMsg(this,"OnPresss", val);        
    22.         }
    23.         void OnSelect(bool val)
    24.         {
    25.                 Debug.Log("I was selected");
    26.                 MessageManager.SendMsg(this,"OnSelect", val);        
    27.         }
    28.         void OnDrag(Vector2 delta)
    29.         {
    30.                 Debug.Log("I am being Dragged");
    31.                 MessageManager.SendMsg(this,"OnDrag", delta);        
    32.         }
    33.         void OnDrop(GameObject go)
    34.         {
    35.                 Debug.Log("I was Dropped");
    36.                 MessageManager.SendMsg(this,"OnDrop", go);        
    37.         }
    38.         void OnTooltip(bool val)
    39.         {
    40.                 Debug.Log("Tooltip Time");
    41.                 MessageManager.SendMsg(this,"OnTooltip",val);        
    42.         }
    43.    
    44. }

    also, using mac os x 10.7.2, I don't see example 5 or 6, just appears as your RTS background image after loading.
     
    Last edited: Jan 7, 2012
  49. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    That's cool, thanks for sharing -- although you can probably get rid of the Debug.Log statements in there ;)

    As for examples 5 6 -- is your target iOS?
     
  50. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    No, not on iOS, just in your web players I don't see them.
     
Thread Status:
Not open for further replies.