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

New UI Widgets

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

  1. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    Added RangeMode option to the ListView in v1.15.2b15
     
    jGate99 likes this.
  2. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    any updates on it :oops:
     
  3. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    added in v1.15.2b16
    scene and scripts at Examples / ListView / GroupedListView / MultipleDefaultItems folder
     
    jGate99 likes this.
  4. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Thank you very much looks great
     
  5. jGate99

    jGate99

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

    Lets say i have a horizontal list view whose "viewport" is stretched (so responsive)

    So if there are less items than viewport width then those items appear in centre, and if there are more items and require scrolling then they can start from left

    I remember u provided a solution like years ago, but i couldnt find it.

    Please advise
     
  6. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    You need to enable ListView.CenterTheItems option.
     
    jGate99 likes this.
  7. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Built in support, amazing
     
  8. jGate99

    jGate99

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

    Can you please develop a new plugin for data visualization from graph charts to bar charts. You already know everything from virtualization to optimization and your support is superb.

    So it'd be great if you come up with a new product and i'd be the first buyer, and im sure there will be many existing users of new ui widgets who'd buy it in first instance.
     
  9. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    I'll think about it but can't promise anything.
     
    jGate99 likes this.
  10. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    I understand starting a new plugin is not an easy task, so just know i'm one of those who'd love get you into visualization. Regards
     
  11. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    I added multiple SnapGrids support, events, SnapMode option to snap at drag or at end drag, and RestoreIfNotSnap option to restore position in v1.15.2b21.

    After rereading your messages, I think ListView with custom Drag&Drop components are more suitable for your needs; please check the Examples / Drag-and-Drop / Inventory scene and scripts (it also was added in v1.15.2b21).
     
    jGate99 and Slashbot64 like this.
  12. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Hi @ilih
    Please remind what sample should i look for best practices for list item having buttons.

    For example, i have a friend reqeusts list item, with accept and reject buttons as well as profile button to see profile, so how do i handle those events?
     
  13. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    Add functions to your DefaultItem class to accept, reject, show profile, then attach those functions to the button OnClick event.
    You can check the Examples / ListView / ListViewWithInputFields scene and scripts, it uses InputFields and Toggle, but the idea is the same.
    upload_2021-12-3_21-33-4.png
     
    jGate99 likes this.
  14. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Thanks for your prompt response :)
     
  15. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    I have just updated New UI Widgets to its latest version, and I am experiencing a problem.

    I was using the 'ListView' class, which is now obsolete and replaced by 'ListViewString'.
    When I call 'DataSource.Clear()', I end up with a null exception in 'ListViewCustom.InitTemplates()':
    Code (CSharp):
    1. template.gameObject.SetActive(true);
    Where 'template' is null.

    What are these templates?
    It is normal that some are null (they aren't all null for me)?
    Can I just add a null-check at that point without risking to break something else?

    [Edit]
    It seems that I have progressed a bit on that.
    It appears that the default items references have been removed.
    That's because I was using 'ListViewStringComponent' as items, and now it is waiting for 'ListViewStringItemComponent'.
    Am I on the right track?

    [Edit2]
    It seems that it was just that, but I won't know for sure before having repaired all the references.
     
    Last edited: Dec 8, 2021
  16. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    Yes, errors happen because of ListView.DefaultItem is null.
    And obsolete
    ListView.DefaultItem
    type is
    ListViewStringComponent
    , and
    ListViewString.DefaultItem
    type is
    ListViewStringItemComponent
    .

    So you need to replace both scripts in the editor or replace the whole ListView gameobject with the new ListViewString.

    Since v1.15.0 ListView can have multiple DefaultItems and use different DefaultItem depending on the item.
    The template is a wrapper for each DefaultItem to keep references on created and cached instances of DefaultItem.
     
    Last edited: Dec 8, 2021
  17. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    Thank you for the confirmation, I've fixed all the default items everywhere, and I have also fixed the colors which were broken, along with the events which were also broken.


    I have faced another problem, it appears that the texts are automatically sorted for ListViewString.
    Before there was a sorting option in the ListView, and I am not finding an equivalent now in the Unity inspector.
    Anyway, my lists weren't sorted before, and now the 'OnSelect' event do not link it to the correct element in the list because the displayed order is different from the order behind the scene.

    It is because we now have to use 'DataSource.Comparison', and by default it is using 'String' comparison.
    I've fixed it by setting 'DataSource.Comparison' to null in the code, but that's a broken change which has a major impact on the behaviour.
    I do not see any reason to force lists of strings to be ordered by default, forcing people to use code to avoid sorting the displayed strings.

    Also, I have seen no indication about that breaking change in the release notes, I really think it should be indicated, as is the breaking change about the cursors (next thing I have to fix, but at least I was warned beforehand).
     
  18. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    Sorry for the problems.
    ListViewString was added in v1.11.2, and ListView was marked as obsolete only in v1.15.1, so the difference in behavior went unnoticed, but I should have checked it more carefully.
    I'll add the EnableSort property to ListViewString in the next update (already added in beta v1.15.2b22).
     
  19. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    No problem here, I know that updating an asset requires some work, especially when there has been a lot of work done on the asset.
    In a way, it's because you work so much that we need some work to update this asset ;)
    So I'm not complaining, I'm just telling you the problems I find so that you can fix/document them for others.


    I may have found something strange about the cursors, I initially tried to put the provided 'Cursors' asset in the 'Cursors' field of the 'Table Header', but I still had the warning.
    According to the code in the 'UICursor.DefaultReset()' that field is not used, but I haven't looked at it really deeply so I may have missed something.
    Anyway, I used the 'Cursors DPI Selector' and it works fine (and that way I have no need to track down all individual 'Cursors' fields... so it's better that way).

    Also, I do have found something strange about 'AutocompleteStringCombobox'.
    If you place one on an empty scene, and add enough data so that there's a scrollbar, then when you click on the scrollbar to drag it, it closes the selection panel.
    A click anywhere else should close the selection panel, but not that scrollbar.
     
  20. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    Also, about the 'AutocompleteStringCombobox', it would be nice if when there's an item selected, when you open the list it is selected.
    Currently the list only contain un-selected items even the one currently in the comboBox.
     
  21. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    Warning displayed if DefaultCursorTexture is not null, but this field is not visible (because the field has unnecessary
    [HideInspector]
    attribute), so the warning can be fixed only with component reset.

    Fixed in v.1.15.2b23

    AutoComboboxString fits better for this purpose: it works with items, so it keeps items selection.
    Added the KeepSelection option to display selected items in Autocomplete list in v.1.15.2b23.

    AutocompleteStringCombobox is a simple autocomplete with Combobox to display all values, it does not have any items support.
     
    Last edited: Dec 9, 2021
  22. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    Thanks for the quick answers.
     
  23. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    v1.15.2 released

    Changelog:
    • added Updater static class to control scripts updates IUpdatable.RunUpdate() without reflection instead of the default MonoBehaviour.Update()
    • added SnapGrid: allow to stick draggable or resizable UI game objects to the nearest grid lines
    • added LinesDrawer and SnapGridDrawer effects
    • COMPATIBILITY-BREAKING CHANGES: MonoBehaviour.Update() replaced with IUpdatable.RunUpdate()
    • Autocomplete: added AllowCancelOnDeselect to cancel DisplayListView close on deselect event.
    • Autocomplete: added OnSearchCompleted event
    • Autocomplete: added ResetListViewSelection option
    • AutoCombobox: fixed InputField display bug
    • AutoCombobox: fixed coloring bug
    • AutoCombobox: added KeepSelection option (set Autocomplete.DisplayListView selected items)
    • Connectors: fixed incorrect positions when CanvasMode is WorldSpace and its scale is not 1
    • Dialog: added ButtonsContainer option
    • ListView: fixed bug with incorrect item sizes when using variable size type
    • ListView: fixed highlighting bug
    • ListView: fixed wrong background color for the last items in table mode
    • ListView: added RangeMode property to determine which element is the start when selecting a range with the Shift key.
    • ListView: fixed instance recycling if ListViewItem.IsDragged enabled
    • ListViewItem: IsDragged renamed to DisableRecycling
    • ListViewString: now sort can be disabled with EnableSort in Inspector window
    • Notification: added ButtonsContainer option
    • Paginator: added SetPage method to change current page without animation
    • Sidebar: added ModalColor field
    • shaders: now should support stereo instanced rendering and SRP batcher (thanks to David Watt)
    • Tooltip: added generic Tooltip
    • TreeView: added FindNodes method
    • Widgets Generation: added Tooltip generation
     
    hopeful likes this.
  24. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    Thanks for fixing 'AutocompleteStringCombobox'.

    I've just updated to v1.15.2 and I have one warning when building a standalone version:
    It happens when I call 'BuildPipeline.BuildPlayer()'.

    Commenting the attribute '[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]' associated to 'Tooltip.TargetInfo.Init()' removes the warning.

    Can you confirm that commenting that line will not cause any problem?
     
  25. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    If need only if you disable "reload domain" in the editor.
    This code does not need runtime, so you can change the directive in the previous line with
    #if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
    instead of commenting attribute.

    What Unity versions have this warning? I did not meet it in builds in 2020.3 and editor mode in all LTS versions, 2021.1 and 2021.2.
     
  26. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    I am using Unity 2021.2.3.
    The message is displayed when I build using a script (I do not use Unity's UI to build a standalone, I have a complex process to execute so everything is scripted).
    It happens when the editor is executing the 'BuildPipeline.BuildPlayer()' instruction.

    Changing the #if won't change a thing, the problem is not when executing the standalone version, it's when building it.
    According to the error (I've been wrong sorry, it wasn't a warning, it was an error), the 'RuntimeInitializeOnLoadMethod' attribute is not allowed for generic classes.
    So it is not executed in the editor.

    It means that commenting it will change nothing as it is not supported by Unity, but the behaviour you intended is probably not correct as it is not executed.
     
  27. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    I rechecked the code and made tests: cache is safe to reuse between play mode runs if "domain reload" is disabled.
    So removing the attribute or deleting the method
    Tooltip.TargetInfo.Init()
    is safe and not breaking anything (method will be removed in the next update).
     
  28. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Hi @ilih
    Can you please add min max date/time support in date time scroller?
    So less than min date/time scroller list items appear differently (greyed out)
     
  29. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    Min-max date/time already exists, and DateScroller/DateTimeScroller values are looped: after the max date will follow min date, same with the min date.
    But if you can add others min-max date time and override YearsValue/MonthsValue/DaysValue/etc methods of Date/DateTimeScroller:

    Code (CSharp):
    1. public DateTime MinGreyDate;
    2.  
    3. public DateTime MaxGreyDate;
    4.  
    5. protected override string YearsValue(int steps)
    6. {
    7.     var date = LoopedYears(steps);
    8.     var is_grey = (date < MinGreyDate) || (date > MaxGreyDate);
    9.     var text = date.ToString(YearsFormat, Culture);
    10.  
    11.     return is_grey ? string.Format("<color=grey>{0}</color>", text) : text;
    12. }
    You need to enable RichText to work it correctly.
     
    jGate99 likes this.
  30. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Thanks @ilih :)
     
  31. KBSMediaDevTeam

    KBSMediaDevTeam

    Joined:
    Jun 15, 2020
    Posts:
    3
    Hello.

    Can I resize and drag the object adding draggable and resizable Component within the bound of the specific area?
     
  32. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    Draggable allows restricting drag within parent borders.
    Resizable currently does not have such a feature; only minimal and maximal size can be specified.
     
  33. KitBarry1809

    KitBarry1809

    Joined:
    Jun 27, 2018
    Posts:
    34
    Hey @ilih I'm trying to use the Context Menu.

    I have a game with some UI elements down the side, and then a bunch of 3D objects in the scene (each hooked up to a ListView item on the UI). You can select an object by selecting its ListView item, or by clicking on the 3D object (soldiers). This is all working great:
    upload_2021-12-27_17-53-40.png

    I want to add a context menu so that when you have a soldier selected, you can right click anywhere on the screen/over the 3D object and set its properties (turn animation on/off, that sort of thing). The problem I have is that the context menu only seems to work over an image on the UI? I can set the image to be transparent, but it blocks my ability to select 3D objects. If I turn RayCast off for the image I can select the 3D objects again but now the context menu doesn't work.

    Is there a way to use the context menu without blocking raycasts?
     
  34. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    You can open the context menu from a script.
    Add Physics Raycast to the camera and attach this script to the objects that should have the context menu.
    Code (CSharp):
    1.     public class OpenContextMenu : MonoBehaviour, IPointerClickHandler
    2.     {
    3.         [SerializeField]
    4.         ContextMenu Menu;
    5.  
    6.         public void OnPointerClick(PointerEventData eventData)
    7.         {
    8.             if (eventData.button == PointerEventData.InputButton.Right)
    9.             {
    10.                 Menu.Open(eventData);
    11.             }
    12.         }
    13.     }
     
  35. KitBarry1809

    KitBarry1809

    Joined:
    Jun 27, 2018
    Posts:
    34
    Fab. Thanks :D
     
  36. jGate99

    jGate99

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

    How can i turn AM/PM from looped to something like in this image?
    So only AM/PM shows and not even looped

    upload_2021-12-28_17-19-56.jpeg
     
  37. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Another problem i noticed is that changing am/pm also changes hours, it is not suppose to change hours or minutes
     
  38. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    I added the TimeScrollerAMMP script in v1.15.3b6, it has a single am/mp option instead of a multiple am/pm.
    Replace the TimeScroller script with this script and copy settings to it.

    You need to enable the IndependentScroll option and check if time fits in the min-max range after am/mp scroll.
     
    jGate99 likes this.
  39. jGate99

    jGate99

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

    How can i force close all the oppened toasts/notify?
     
  40. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    For now, the only way is this:
    Code (CSharp):
    1.             foreach (var notify in FindObjectsOfType<Notify>())
    2.             {
    3.                 if (!notify.IsTemplate)
    4.                 {
    5.                     notify.Hide();
    6.                 }
    7.             }
    In the next update will be added OpenedNotifications property to the notification class.
     
    jGate99 likes this.
  41. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Hi @ilih
    most recent beta update seems to make AM/PM broke
    https://we.tl/t-eB0gs0R3Rn

    Secondly if we create new from menu > Input > DateTimeScroller
    that newly created control doesnt scroll with animation
     
    Last edited: Jan 3, 2022
  42. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
  43. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    fixed in v1.15.3b9
     
  44. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Still its not scrolling smoothly, even if i create an entirely new DateTimeScroller using UI > Input ... using Unity 2020.3.23f1
     
  45. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    Does the problem happen with a mouse wheel or drag or both?
     
  46. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    simple drag even on newly generated date scroller using right click > Ui Widghets > Input > Date Scroller
     
  47. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    Please check ScrollBlock properties for each *Scroller in DateScroller.
    Maybe Always Center disabled or Time to Stop have the wrong value.
    upload_2022-1-4_19-14-57.png

    In the last update, I fixed a rare bug with scroll inertia stopping at the wrong position, but in your video, it looks like there is no inertia at all.
     
    jGate99 likes this.
  48. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Exactly no inertia at all, if i use UIWidgets.1.15.3b9-2020.3.0f1
    Even in newly created DateScroller

    upload_2022-1-4_22-23-25.png
     
  49. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,402
    Are there any errors in the console log?
    And is the "New UI Widgets Updater Proxy" game object enabled in play mode?

    Also please check at an empty project with only v1.15.3b3 imported.
     
  50. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,935
    Its not available
    New UI Widgets Updater Proxy

    How do i manually add it?