Search Unity

New UI Widgets

Discussion in 'Assets and Asset Store' started by ilih, Feb 11, 2015.

  1. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @ilih,

    https://we.tl/t-Te7dTTL1K7

    now "Big with speed" is faster, however there is one last thing missing
    if you scroll down (from 1st to 100 items) then its faster = perfect

    but if you start to scroll up (from 100 to first item) then its slow again, if you can solve this too then it'd be perfect for both cases, I'm also sharing project in PM
     
  2. Valdarix

    Valdarix

    Joined:
    Jul 24, 2018
    Posts:
    4
    I apologize if this is just me misunderstanding a setting or something but using keyboard to navigate the list view feels off, when I use the keyboard the focus jumps back to the top of the list before it scrolls anything. See gif for what I mean. It scrolls by 1 element each time, jumping to the top of the list.
    Unity_o5XdMb07Nu.gif

    Is there a setting I don't understand that causes this or is that just the way it is designed?
     
    cgrow67 likes this.
  3. Valdarix

    Valdarix

    Joined:
    Jul 24, 2018
    Posts:
    4

    Nevermind, I see what it is doing, If the mouse cursor is left in the list view it jumps back to the cursor position. Sorry for wasting your time.
     
    ilih likes this.
  4. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Sorry, it was my mistake.
    Fix:
    Replace line in Scripts / ScrollRectUtilities / ScrollRectDragSensitivity.cs
    old line:
    var offset = CalculateOffset(delta - ScrollRect.content.anchoredPosition, ref view_bounds);

    new line:
    var offset = CalculateOffset(StartPosition + delta - ScrollRect.content.anchoredPosition, ref view_bounds);
     
  5. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    No problem. UI "feature" to have two highlighted game objects (one from mouse, the other from keyboard/gamepad) cause problems sometimes.
     
  6. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @ilih
    any update on this?
    Thanks
     
  7. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Probably you missed my message.

    Duplicate:
     
    jGate99 likes this.
  8. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Thanks, it worked
     
  9. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @ilih,

    There are 2 more improvments needed:
    If you look at the last apk 3rd scene (big with speed) which uses your new scroll component.

    1- If we scroll fast, then some items seems to overlap or have short item height even though i set minHeight

    2- While list is scrolling and we swipe to scroll again, then what happens is that scrolling immediatly stop and then scroll (it happens in split seconds) but its notice able, Is there any way to improve this?

    Thanks
     
  10. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Please try to change ListType to List View With Variable Size.

    Maybe reducing EventSystem.DragThreshold can help or increasing Input Actions Per Second.
     
    jGate99 likes this.
  11. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @ilih
    The project i sent, if you check its big but speed scene, and notice when its about to stop scrolling it sort of "vibrates"
    do you notice that? if so can you please solve this
     
  12. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    If it is still actual: you can enable InputSystem (and change "Active Input Handling" to "Both" in Player settings) and replace Standalone InputModule with InputSystem UI InputModule on the EventSystem game object.
    It will prevent highlight and cursor jump because of this limitation: "UI will not react to a pointer's position until the position is changed".
     
  13. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Not noticed it, I will check it.
     
    jGate99 likes this.
  14. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @ilih
    How do i detect 1 Second before scrolling is going to stop?
    This is how things happen in scrolling
    1- Start Scrolling
    2- List is Scrolling
    3- List is slowing down (i want to detect this as X number of seconds, so this way i can do something before 1 second or 3 seconds of scrolling end happens, I understand user can scroll again but thats not an issue)
    4- Scrolling End
     
  15. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
  16. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @ilih,
    I get this error on android only in build and not in editor, please advise

    NullReferenceException: Object reference not set to an instance of an object.

    UnityEngine.RectTransform.get_rect () (at <00000000000000000000000000000000>:0)
    UIWidgets.ListViewItem.OnRectTransformDimensionsChange () (at <00000000000000000000000000000000>:0)
    UIWidgets.UpdaterProxy.RunOnceActions () (at <00000000000000000000000000000000>:0)
    UIWidgets.UpdaterProxy.Update () (at <00000000000000000000000000000000>:0)
     
  17. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Its caused by Canvas Scaler, try to change Reference Screen Resolution.
    You have 1600x900 (16:9), but the actually used on portrait mode (aspect ratio 9:16 or maybe even more).
    Try to change it 900x1600 or another value closer to the real screen.

    Fixed in v1.15.4b11.

    I'll look into it.
     
    jGate99 likes this.
  18. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    If i set End Scroll Delay to negative value will it trigger on scrolling end earlier?
     
  19. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    No.

    Please update to v1.15.4b12
    After it you can use the following script (attach it to ScrollRect) to get time in seconds when ScrollRect stops.
    Code (CSharp):
    1.     using System;
    2.     using UIWidgets;
    3.     using UnityEngine;
    4.     using UnityEngine.Events;
    5.     using UnityEngine.EventSystems;
    6.     using UnityEngine.UI;
    7.  
    8.     [RequireComponent(typeof(ScrollRect))]
    9.     public class TimeToStop : MonoBehaviour, IEndDragHandler
    10.     {
    11.         [Serializable]
    12.         public class TimeEvent : UnityEvent<float>
    13.         {
    14.         }
    15.  
    16.         [SerializeField]
    17.         public TimeEvent StopAfter = new TimeEvent();
    18.  
    19.         [SerializeField]
    20.         public float StopVelocity = 1f; // can be increased to 5..10
    21.  
    22.         [SerializeField]
    23.         public float TimeStep = 0.033f; // reduce to increase accuracy
    24.  
    25.         ScrollRect scrollRect;
    26.  
    27.         void Start()
    28.         {
    29.             scrollRect = GetComponent<ScrollRect>();
    30.         }
    31.  
    32.         public void OnEndDrag(PointerEventData eventData)
    33.         {
    34.             var time = UtilitiesScrollRect.TimeToStop(scrollRect, StopVelocity, TimeStep);
    35.             StopAfter.Invoke(time);
    36.         }
    37.     }
     
    jGate99 likes this.
  20. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @ilih,

    I'm using Multiple List View as Group Lists (which uses IListViewTemplateSelector and have 5-6 templates), there are lets say 15 Screens with exactly same list views.

    It'd be really great if you can provide a performance update feature where all those 15 ListViews can point to a shared TemplateSelector and Pool Component Items from It, This i believe will improve performance a lot because there will b less Component Items rather than 15 having their own 5-6 templates multiplaying turning into huge memory consumption.

    Thanks
     
  21. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    You can use single template selection for multiple ListViews:
    Code (CSharp):
    1. var selector = new Selector(); // or any other way to create selector
    2. ListView0.TemplateSelector = selector;
    3. ListView1.TemplateSelector = selector;
    4. ListView2.TemplateSelector = selector;
    I'll think about the shared components pool.
     
    jGate99 likes this.
  22. cgrow67

    cgrow67

    Joined:
    May 31, 2016
    Posts:
    52
    ---------------------------
    I'm having something that looks exactly like this problem on all lists when the mouse enters and then the selection continues down endlessly.
    It seems like the down arrow key is being held down after the mouse selection occurs.
    If I disable Navigation the problem does go away so it is a keyboard thing.

    I also find that it happens in the example scenes the Widget generator creates.

    I will admit that my widgets were create many years ago and I recently updated to the latest - 1.15.3f2.
    However, I did create new widgets today which contained the same problem.

    Thank you for any help you might have.



    Chris
     
    Last edited: Mar 22, 2022
  23. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    What input module are you using: Standalone Input Module or Input System UI Input Module?
    You can check it on the Event System game object.

    Navigation events also can be raised by a gamepad, sometimes unintentionally because of sticks drift.
     
  24. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Yes, please , this will be huge if 10-15 list view of exact same type and exact same Selecteor could share the same component pool
    (keeping my fingers crossed)
     
  25. cgrow67

    cgrow67

    Joined:
    May 31, 2016
    Posts:
    52
    Okay... this is beyond Funny... Stick drift..

    So, our application is mainly a business app and we don't use joystick input at all.

    However, as a hobby I'm into DCS and Flight Simulator and have a nice HOTAS ( Joystick, Pedals and Throttle ) setup.
    As it turns out, my throttle is normally left at full or off which leaves the axis at full deflection.

    When I run our product.. oddly.. I can drive the list views with the right throttle.
    The joystick, pedals and many other rotary axes on the throttle are unresponsive.

    is there any way to disable this behavior or control what axes its using as input?

    As a note: we use the Standard Event System.. only because it hasn't been to important.
     
  26. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Here are solutions for the different input modules.

    Standalone Input Module:
    • open Project Settings / Input Manager
    • change Sensitivity to 0 for "Horizontal" with Type = Joystick Axis (there are two "Horizontal", another one for keyboard)
    • same for the "Vertical"

      Or rename those "Horizontal" and "Vertical" records to names not used by Standalone Input Module
      upload_2022-3-23_18-50-27.png
    Input System UI Input Module:
    • open Project Settings / Input System Package
    • add keyboard, mouse, and other required devices to the Supported Devices
      upload_2022-3-23_18-51-29.png
     
    Last edited: Mar 23, 2022
    cgrow67 likes this.
  27. cgrow67

    cgrow67

    Joined:
    May 31, 2016
    Posts:
    52
    This worked perfectly!!
    Thank you again for the help.
     
  28. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    241
    Hi, great asset!

    I want to use drag&drop in ListView, but I get an error when I drag out the last element from a list. This can be reproduced in the provided ListViewMain example scene: just drag out all the items from the middle list into the left list. Once the last item is dragged out, there is an ArgumentOutOfRangeException.
     
  29. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    It is already fixed in v1.15.4f1
     
  30. Faikus

    Faikus

    Joined:
    Jan 3, 2011
    Posts:
    241
    Thanks!
     
  31. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    v1.15.4f1 released

    Changelog:
    • added ScrollRectDragSensitivity
    • added UtilitiesScrollRect: get time for ScrollRect stop by inertia
    • ListView: added ReversedOrder option (items displayed from end to start)
    • ListView: added OnlyOneHighlighted option
    • ScrollRectHeader, ScrollRectFooter: added Visible option to show and hide header (or footer)
    • ScrollRectHeader, ScrollRectFooter: added layout support if DisplayType is Reveal
    • ScrollRectFooter: added ChangeLayout option
    • ScrollRectPaginator: added RoundingError option to avoid excess last page
    • Switch: added AnimationCurve option
    • Widgets Generation: fixed enum related bug
    • Widgets Generation: improved support of latest Unity versions
    • Style: fixed “Create Style” bug
     
    jGate99 likes this.
  32. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @ilih
    This is regarding ScrollRectDragSensitivity which increases scrolling speed,
    however there is a UX thing that require improvement,

    Currently if you test it on mobile apk you will notice both scrolling (after swiping) as well as while you are not swiping but moving/dragging your finger slowly/normaly up and down and items scroll away really faster

    So ideal behaviour is, when user is not swiping then scroll sensitivty remains old behaviour, but when user swipe (like he intends to scroll fast) then scroll sensivity triggers.

    Please let me know if its clear or not, if its not clear then ill record a video.

    Thanks
     
  33. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    You can decrease ScrollRect.inertia, so the scroll will be faster and longer after swipe.

    Or you can change ScrollRect.velocity on end drag event with the next script.
    But it will look like sudden acceleration.
    Code (CSharp):
    1.     [RequireComponent(typeof(ScrollRect))]
    2.     public class ScrollRectAcceleration : MonoBehaviour, IEndDragHandler
    3.     {
    4.         [SerializeField]
    5.         public Vector2 acceleration;
    6.  
    7.         public virtual void OnEndDrag(PointerEventData eventData)
    8.         {
    9.             if (eventData.button != PointerEventData.InputButton.Left)
    10.             {
    11.                 return;
    12.             }
    13.  
    14.             var sc = GetComponent<ScrollRect>();
    15.             sc.velocity *= acceleration; // can be added check on minimum velocity to apply acceleration
    16.         }
    17.     }
     
    jGate99 likes this.
  34. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    So should i use this component without ScrollSensitivty or with it?
     
  35. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Without ScrollRectDragSensitivity.
     
    jGate99 likes this.
  36. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @ilih
    Any thoughts on it?
     
  37. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Still working on it.
     
    jGate99 likes this.
  38. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Thanks
     
  39. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Shared components pool added in v1.15.5b1.
    ListViews should have same DefaultItem or TemplateSelector (they can be different, any benefit will be only for the same DefaultItem instances).

    Usage:
    Code (CSharp):
    1. [SerializeField]
    2. List<ListViewIcons> ListViews;
    3.  
    4. List<ListViewIcons.Template> SharedTemplates = new List<ListViewIcons.Template>();
    5.  
    6. public void SetShared()
    7. {
    8.     foreach (var lv in ListViews)
    9.     {
    10.         lv.SetSharedTemplates(SharedTemplates);
    11.     }
    12. }
    13.  
     
    jGate99 likes this.
  40. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Thanks @ilih
    Is there a example scene included?
     
  41. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Scene in attachment.
     

    Attached Files:

    jGate99 likes this.
  42. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @ilih
    How do i close all the open dialogs? is there a function for that
     
  43. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    You can iterate open dialogs and close each of them.
    Code (CSharp):
    1. foreach (var d in Dialog.OpenedDialogs)
    2. {
    3.     d.Hide();
    4. }
    If you have your own dialog classes then do the same for them.
     
    jGate99 likes this.
  44. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    So How can i Hide but also invoke close event but with -2,
    reason is -1 is for (top right close x button)
    and -2 so i know we closed the popups right before lets say scene unloading we act acordingly (different than -1)
     
  45. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    You can use
    dialog.Cancel()
    instead of
    .Hide()
    .
    The
    Cancel()
    method invokes both OnDialogCancel and OnClose callbacks.
    The
    Hide()
    method invokes only OnClose callback.

    Another way is to manually invoke events:
    Code (CSharp):
    1. foreach (var d in Dialog.OpenedDialogs)
    2. {
    3.    var hide = d.OnDialogCancel != null ? d.OnDialogCancel(d, -2) : true;
    4.    if (hide)
    5.    {
    6.       d.Hide();
    7.    }
    8. }
     
  46. cgrow67

    cgrow67

    Joined:
    May 31, 2016
    Posts:
    52
    Today I upgraded from 14.1 to the latest version and now I'm getting the following errors.
    As I examined the code it looks like class name changes caused the source file names to change.
    I worry about altering your code.

    Any idea what might have happened?
    Is there a good way to clean this up?
     

    Attached Files:

  47. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Probably because TabButtonGeneric.cs was renamed to TabButton{TTab}.cs
    Delete TabButtonGeneric.cs to fix it.
    Usually, Unity properly renames the file if it has the same GUID in the metafile.
     
  48. cgrow67

    cgrow67

    Joined:
    May 31, 2016
    Posts:
    52
    After the update to 1.15x, while using a TileView, I've noticed that the onItemSelect event fires when an item is hot tracked and not on select as it did in 1.4. The selection hasn't changed but the event fires anyway. I could see having an event fire for this but shouldn't it be a different event? Maybe onItemHotSelect or something like that? Normally this wouldn't be a big deal but when this event fires we normally have a very time consuming operation to do (Engineering/Design). It makes the TileView very painful. I will add some code to shunt it for now but others may have issues with this also.
     
    Last edited: Apr 13, 2022
  49. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Disable the "Keep Highlight" option.
    If this option is enabled then the item will be selected by EventSystem on the PointerEnter event.
    upload_2022-4-13_18-48-7.png
     
    Last edited: Apr 13, 2022
  50. cgrow67

    cgrow67

    Joined:
    May 31, 2016
    Posts:
    52
    Thank you.. this was perfect!