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
    Edit: Odd. I'm going to look into this.
     
    Last edited: Mar 22, 2012
  2. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    1.86e is up with a fix for this.
     
  3. trelobyte

    trelobyte

    Joined:
    Nov 17, 2010
    Posts:
    54
    You are superfast ArenMook !!! thanks you very very much :)
     
  4. YueFeng

    YueFeng

    Joined:
    Feb 14, 2010
    Posts:
    24
    HI,ArenMook.
    I purchased NGUI and have a question.
    When I used OnPress function and pressed the button, it called twice when press and release.....
    Which function only called once when you press and don't called when release?
    Thanks!!
     
  5. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,203
    You want "OnClick()"
     
  6. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    Also, OnPress takes a bool parameter OnPress(isPressed) - you can check to see if isPressed is true before doing anything.
     
  7. Asse83

    Asse83

    Joined:
    Aug 1, 2009
    Posts:
    169
    Hey Aren,

    I have issues with the order when mixing gui elements that use textures from an atlas with elements that use another texture (e.g. icons that can't be put onto the atlas). Do you have any recommendations for handling this?
     
  8. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Separate that into 3 panels, each panel offset by Z. Background, icons, overlay.
     
  9. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    I'm sorry if I intrude even if I still don't have NGUI (still planning to get it in the future, probably). But shouldn't OnClick be called when a button is pressed and then released?
     
  10. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    OnPress is the right function to use. The function's boolean parameter just needs to be checked -- true if the press started, false if it ended.
     
  11. mohydineName

    mohydineName

    Joined:
    Aug 30, 2009
    Posts:
    301
    Hello,

    Is there any documentation on how to create a slicedsprite?

    Thanks
     
  12. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Meaning... create it in the atlas? Create it in the scene?
     
  13. mohydineName

    mohydineName

    Joined:
    Aug 30, 2009
    Posts:
    301
    In the atlas
     
  14. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Same as a regular sprite, just add a border.
     
  15. YueFeng

    YueFeng

    Joined:
    Feb 14, 2010
    Posts:
    24
    hi,ArenMook.
    I purchased NGUI and have a question.
    I want the button only called once when it press, don't called when release. But I used OnPress function it called twice when press and release.Which event function should I use ?
    Thanks!
     
  16. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Check the parameter, YueFeng:

    Code (csharp):
    1. void OnPress (bool isPressed)
    2. {
    3.     if (isPressed) ... do something
    4. }
     
  17. YueFeng

    YueFeng

    Joined:
    Feb 14, 2010
    Posts:
    24
    How to set the button called(and change the press texture of imageButton) when fingers sliding from the periphery sliding to the button area , default button must "touch" the collider area.

    I used it on IOS platform, thanks!
     
    Last edited: Mar 23, 2012
  18. Pedro Figueira

    Pedro Figueira

    Joined:
    Mar 23, 2012
    Posts:
    3
    Greetings.

    So far i'm liking the tool. But i'm having a hard time figuring out how to set Ints via NGUI such as volume using the slider OnSliderChange class.

    I might be missing something basic here, could anybody help me?
     
  19. cjow

    cjow

    Joined:
    Feb 29, 2012
    Posts:
    132
    Is it possible to have 2 separate clipping areas for the same object? For example I have a scene where I have some scroll list of objects at the bottom which I'd like to be confined to a certain width but when I drag the objects out of the list the clipping area should be wider. Here's a quick idea of what I mean.

    The red areas represent where the object should get clipped.
     

    Attached Files:

  20. KevinJohnson25

    KevinJohnson25

    Joined:
    Feb 23, 2011
    Posts:
    35
    @Pedro
    If you want to use a slider to change the volume, you can pass the sliderValue variable from the UISlider script to whatever object is controlling the volume.

    @ArenMook
    I've just run into an issue that I'm not sure how to approach. I've got a scrolling list with a setup very similar to new Better Scroll View example except that I'm letting my UIGrid object move the panel contents as well as each button (they're spaced out a bit and I want the user to be able to scroll through the list from anywhere on the screen). The issue I have now, that wasn't present in previous versions, is that I can't get the buttons to register an OnClick event unless I tap the button VERY quickly. It seems like any movement will turn the touch into a drag and button will not get the OnClick event. I need to be able to have drags on the buttons move the list, but for regular taps (or within a movement threshold) activate the button's function. Like I said, this used to work a versions back but now it doesn't. I'm using Unity 3.4.2 and publishing to iOS if that helps.

    Thanks!
    Kevin
     
  21. peabulls

    peabulls

    Joined:
    Mar 23, 2012
    Posts:
    1
    hello, and thanks for the nice tool ..

    i'm having a weird issue: i have a list of elements that is generated at runtime (the number of items changes on a regular basis) .. i have it set up to scroll using a ui drag camera script (constrained to the y axis) attached to the elements in the list

    when the number of elements in the list change i reset the camera's position so the list appears to have moved back to the top of the list .. this works in all but one situation:

    the list is scrolled past the bottom most element and springs back .. in that case resetting the camera's position does not work .. if i turn off the momentum and spring effect .. the list resets just fine ..

    do you have any ideas what i might be doing wrong? thanks in advance
     
  22. cjow

    cjow

    Joined:
    Feb 29, 2012
    Posts:
    132
    @Pedro Figueira:

    On the slider object in the UISlider script there's an area called "Funtion Name" which by default is set to OnSliderChange. In your script you can then write

    Code (csharp):
    1.  
    2. float someValue;
    3. float maxSliderVal;
    4.  
    5. void OnSliderChange(float val)
    6. {
    7.     someValue = val * maxSliderVal;
    8. }
    9.  
    val always represents the slider from 0 to 1 so by multiplying it by the maximum value you want the slider to represent you can change someValue from 0 to maxSliderVal by moving the slider.

    To have the slider then affect the volume just set the source's volume to equal someValue.
     
    Last edited: Mar 23, 2012
  23. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    @CJO: You can't have two clipping areas. You can, however, fake it, by adding high-depth widgets to a bigger scroll view that will hide the bottom right and bottom left corners.

    @KevinJohnson25: Oddly enough, the changes I made should have had the opposite effect. Take a look at UICamera line 708:

    Code (csharp):
    1. float threshold = (currentTouch == mMouse) ? 10f : Screen.height * 0.1f;
    That's the section that checks to see if the object has been dragged too far, and if it has, click notification gets turned off. Currently on iOS that's set to 10% of the screen, which is fairly significant. You can play around with the values until you get something that feels right to you.

    @peabulls: You need to disable the spring effect on your camera. Just get the SpringPosition component and disable it.
     
  24. Pedro Figueira

    Pedro Figueira

    Joined:
    Mar 23, 2012
    Posts:
    3
    Oh boy, C# haunts me once more

    Thanks guys, i'll try!
     
  25. Legacy

    Legacy

    Joined:
    Oct 11, 2011
    Posts:
    651
    Hey aren, is there a way to fade in and out ngui widgets? i was looking at itween fadeto method but since there is no material attached to the widgets and all of the widgets come from the same atlas i dont think it will work.
     
  26. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
  27. cjow

    cjow

    Joined:
    Feb 29, 2012
    Posts:
    132
    You can do it with JS if you prefer although I don't think Boo is supported :)
     
  28. jaegis07

    jaegis07

    Joined:
    Apr 6, 2010
    Posts:
    8
    I import NGUI free into my project. The button function doesnt work. The Init() function of UIButtonScales.... is not called in the script. However, when I create an empty project and import NGUI, it works !
    You have any idea how to fix that ?
    Thanks a lot.
     
  29. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Edit -> Project Settings -> Physics, check "Raycast Hit Triggers".
     
  30. YueFeng

    YueFeng

    Joined:
    Feb 14, 2010
    Posts:
    24
    How to set the button called(and change the press texture of imageButton) when fingers sliding from the periphery sliding to the button area , default button must "touch" the collider area.

    I used it on IOS platform, thanks!
     
  31. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    Why should Boo not be supported? Boo wasn't supported on iOS until Unity 3.0 due to issues with AOT-compilation. See also Manta's reply at boo?:

    So if JS works, Boo also works (not that I personally care about either of those two - C# gives me all I want and need).
     
    Last edited: Mar 26, 2012
  32. Adiel

    Adiel

    Joined:
    Feb 20, 2012
    Posts:
    8
    I would like to disable multi touch for iPhone/Android input(Simply put, only one button will be pressed by the first touch).
    Is there an easy way to do this or do I need to mess with the code?
    Thanks.
     
  33. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    @YueFeng: I am not sure what you mean.

    @Adiel: You will need to fiddle around with UICamera's code.
     
  34. Adiel

    Adiel

    Joined:
    Feb 20, 2012
    Posts:
    8
    Thanks for the quick reply :)

    EDIT:
    well, it seems that Input.multiTouchEnabled = false; does the trick anyway :)
     
    Last edited: Mar 26, 2012
  35. YueFeng

    YueFeng

    Joined:
    Feb 14, 2010
    Posts:
    24
    Sorry,perhaps my expression not quite understand.
    I mean wherever your finger touch, once the touch position drag into the button area ,it called(Button texture state toggle for press),and once the touch position drag off the button area, button texture state toggle for normal.....
    How should I do? Thanks you.
     
  36. YueFeng

    YueFeng

    Joined:
    Feb 14, 2010
    Posts:
    24
    I draw a rough picture of instructions , I don't know whether to understand . :(
     

    Attached Files:

    • $1.png
      $1.png
      File size:
      12.9 KB
      Views:
      1,591
    • $2.png
      $2.png
      File size:
      21.9 KB
      Views:
      1,611
    • $3.png
      $3.png
      File size:
      23.9 KB
      Views:
      1,530
  37. KevinJohnson25

    KevinJohnson25

    Joined:
    Feb 23, 2011
    Posts:
    35
    @ArenMook: Ok, I've found that it's not the threshold that affecting the buttons. I increased it to half the screen and the buttons still don't trigger unless I tap very quickly. The buttons go through their size tween so I know that OnPress is working, but for some reason OnClick won't fire when the touch ends. Any idea why this might happen? The only other thing I can think of is that there's some kind of conflict with the button colliders and the collider on my UIGrid object but then OnPress wouldn't work, right?

     
  38. KevinJohnson25

    KevinJohnson25

    Joined:
    Feb 23, 2011
    Posts:
    35
    Oh, and I guess I should mention that everything works the way it should in the Editor. It's only when I build to the device to I get the weird behavior.
     
  39. theHost

    theHost

    Joined:
    Nov 30, 2009
    Posts:
    37
    I am getting the same issue after I updated to 1.87. The OnPress gets called, but not the OnClick; and this only happens on the iOS devices.
     
  40. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    @YueFeng: NGUI doesn't work that way. Once you press down on something, that something will be receiving drag events. This is standard behavior in every UI system. If you wish to change it, you will need to modify the UICamera class.

    @KevinJohnson25 and @theHost: That's odd, I'm going to take a look at it.
     
  41. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Sorry for the beginner question but I took a look through the examples and tried to figure it out but i'm at a loss. If I have a UILabel, how do I specify at what point the text should do a carriage return and start on a new line? I've tried modifying Line Width but that doesn't seem to change anything.
     
  42. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Line width is it -- specify it in pixels.
     
  43. ArcDragon

    ArcDragon

    Joined:
    Feb 21, 2012
    Posts:
    23
    Hello.
    suddenly,I have this error.

    Assets/NGUI/Scripts/UI/UISlicedSprite.cs(39,30): error CS0115: `UISlicedSprite.UpdateUVs()' is marked as an override but no suitable method found to override

    What is this?
     
  44. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    UISprite, line 202:
    Code (csharp):
    1. virtual public void UpdateUVs (bool force)
    UISlicedSprite derives from UISprite. My guess -- you added some package that defines its own "UISprite" class, such as EZGUI. Either that, or (if you just updated) something didn't update fully for you. File -> New Scene, delete the NGUI folder from the Project view, and import from the updated package.
     
  45. Asse83

    Asse83

    Joined:
    Aug 1, 2009
    Posts:
    169
    Hey, the problem is that the icons are completely implemented into the gui within e.g. scroll-lists and so on and I also need to create prefabs that use the atlas and icons in one object.

    So may it be possible to completely use the .z sorting for managing the order (I only use 2d so this would be ok)?
     
  46. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    You could, if you created a ton of panels everywhere (under every widget), but I seriously don't recommend this approach. Not only would it result in a massive number of draw calls, but it will also make it much more difficult to work with. You can still use the approach I suggested (3 panels) even with icons that use different non-atlased widgets. Just ensure that the *overlay* uses its own panel. I do the same thing for the game map of the game I'm working on. The window is drawn first by one panel, then a new panel is used to draw the map (render texture using UITexture), which is offset along the Z, and the same panel is used to draw the overlay widget (border, tinting), which is offset along the Z even more.
     
  47. ArcDragon

    ArcDragon

    Joined:
    Feb 21, 2012
    Posts:
    23
    @ArenMook
    Thank you!
    Project recovered!
     
  48. totaldang

    totaldang

    Joined:
    Mar 22, 2012
    Posts:
    2
  49. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Make one row, save it as a prefab, then dynamically add instances of this prefab to a UITable, filling in the contents in the process. Sorting has to be done manually, it it's pretty easy to do. The UITable is capable of sorting things for you alphabetically, so all you have to do is name them in the order that you want them to appear in.
     
  50. yuewah

    yuewah

    Joined:
    Sep 21, 2009
    Posts:
    98
    UIGeometry.cs

    Code (csharp):
    1. public void ApplyTransform (Matrix4x4 widgetToPanel, bool normals)
    2. {
    3.     if (verts.size > 0)
    4.     {
    5.         mRtpVerts.Clear();
    6.         foreach (Vector3 v in verts) mRtpVerts.Add(widgetToPanel.MultiplyPoint3x4(v));
    I think you are missed to change loop of verts from " foreach ( ... ) " to " for ( i = ... ) "
     
Thread Status:
Not open for further replies.