Search Unity

New UI Widgets

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

  1. tim44

    tim44

    Joined:
    May 15, 2019
    Posts:
    58
    Listview.ScrollToPosition(-10f);
    fixes it after load
     
  2. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Is list type is List View With Variable Size or Tile View With Variable Size?
    I'll think I fixed this bug in one of the 1.11.2 beta versions. Please check it.
     
    tim44 likes this.
  3. Petskus

    Petskus

    Joined:
    Jan 29, 2019
    Posts:
    25
    How is correctly from code set item size of TileView with Fixed Size?
     
  4. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    You need to change DefaultItem size and re-set DefaultItem.
    Code (CSharp):
    1.             var rt = ListView.DefaultItem.transform as RectTransform;
    2.             rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
    3.             rt.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);
    4.             ListView.DefaultItem = ListView.DefaultItem;
     
    Petskus likes this.
  5. jGate99

    jGate99

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

    If i call UpdateItems() on an inactive listview, i get this error.
    Please advise

    Code (CSharp):
    1.  
    2. NullReferenceException: Object reference not set to an instance of an object
    3. UIWidgets.ListViewCustom`2[TComponent,TItem].FindItem () (at Assets/New UI Widgets/Scripts/ListView/ListViewCustom.cs:1135)
    4. UIWidgets.ListViewCustom`2[TComponent,TItem].get_HighlightedIndices () (at Assets/New UI Widgets/Scripts/ListView/ListViewCustom.cs:1099)
    5. UIWidgets.ListViewCustom`2[TComponent,TItem].ComponentsHighlightedColoring () (at Assets/New UI Widgets/Scripts/ListView/ListViewCustom.cs:1124)
     
  6. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Please try this:
    replace line in ListViewCustom.cs in FindItem() function:
    Code (CSharp):
    1.             var root = Utilites.FindTopmostCanvas(transform).transform as RectTransform;
    with new lines:
    Code (CSharp):
    1.             var canvas = Utilites.FindTopmostCanvas(transform);
    2.             if (canvas == null)
    3.             {
    4.                 return null;
    5.             }
    6.             var root = canvas.transform as RectTransform;
     
  7. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
  8. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    jGate99 likes this.
  9. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    awesome
     
  10. Kaneleka

    Kaneleka

    Joined:
    Sep 23, 2013
    Posts:
    18
    Am I the only one seeing crazy build times on 2019.3 when using this asset? I love this asset but I have to manually comment out the attribute [UnityEditor.Callbacks.DidReloadScripts] on the highlighted script below and the one below it for it to be usable.

    upload_2020-2-9_10-6-42.png
     
  11. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    I have a few ideas about why AssetDatabase.FindAssets can work slow:

    1. Maybe you have a lot of files in the project, or Asset Pipeline V2 in 2019.3 caused FindAssets performance degradation.

    In such cases restricting search to use only the specified folder should be faster:
    file "New UI Widgets/Editor/AssemblyDefinitionsEditor.cs", function Get
    replace line:
    var guids = AssetDatabase.FindAssets(search);

    with new line:
    var guids = AssetDatabase.FindAssets(search, new string[] { "Assets/New UI Widgets" });


    Also, you can try to switch Project Settings/Editor/Asset Pipeline to Version 1 until a version with the fixed performance released.

    2. Check the drive state, maybe it malfunctioning and AssetDatabase.FindAssets works slowly because of the read errors.
     
    hopeful likes this.
  12. Petskus

    Petskus

    Joined:
    Jan 29, 2019
    Posts:
    25
    How can I disable caching in TileView?
    It seems that scroll in TileView works less smoothly than standart ScrollRect.
     
  13. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    I added the Virtualization option to disable caching in v1.11b14.
     
  14. jGate99

    jGate99

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

    Diallog currently has only one 1 type of button,
    usually we have 2 types of template button, where one is like "reply" and other buttons are like Cancel. So please add that extra button.

    Also plz add pooling support for these buttons.

    Thanks



    day_099_-_message_notification.jpg
     
  15. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    OK, I'll try to add it.
     
    jGate99 likes this.
  16. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Please check v1.11.2b17

    The Dialog now has ButtonsTemplates property instead of the DefaultButton.
    And you can specify button index in the actions:
    Code (CSharp):
    1.             var actions = new DialogActions()
    2.             {
    3.                 { "Button 1", Dialog.Close, 1 },
    4.                 { "Button 2", Dialog.Close, 0 },
    5.             };
     
    jGate99 likes this.
  17. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Wow, really appreciate that.

    I have another request (not so urgent though so please do it in your leisure time).
    Capture.PNG

    If you look at attached screenshot, (50% Off, Get Premium Text, Red Color)
    Its a "virtualized" carousel with left and right items partially visible.

    This is quite popular these days, so it'd be really great if UI Widgets have this control too.

    Thanks again
     
  18. jGate99

    jGate99

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

    Can you please provide an alternate but more performance friendly implementation of Dialogs which uses List instead of Dictionary and follow listed below strcuture or improved, this way i can reuse same List instance, by only changing label names.

    class ButtonInfo{

    Label = "Hello",
    ButtonIndex = 0// for template,
    OnClickHandler = ClickHandler

    }

    List<ButtonInfo>

    ====

    This way i can simply change label of existing reusable instance of List by simply List[0].Label = "Ok"
    This avoids any lambda, or Linq.

    Thanks
     
  19. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    OK
     
    jGate99 likes this.
  20. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Thanks for making new ui widgets better every day,
    So when you do this new List based implementation please use IList so we can pass both arrays and List. Also instead of seperate callbacks, now we have IList with index of each button so a genric callback like this
    bool onClickHandler(buttonIndex);
    will serve good without need for defining multiple callbacks.

    Thanks


    To summerize all

    class ButtonInfo{
    Label = "Hello",
    ButtonTemplateIndex = 0// for template,
    }

    //buttons
    IList<ButtonInfo> ButtonsData;


    //shared click handler
    bool onClickHandler(buttonIndex);


    Update 3:
    and for cross button (top right), you can return -1 for onCickHandler
     
    Last edited: Feb 23, 2020
  21. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @ilih,
    in next update, please make Tooltip a partial class, so we can easily add custom methods without extending from it.
    thanks

    Update 2:
    Looks like simply partial is not enough as UIWidgets uses a different assembly,
    so ill have to now inherit it.
    Thanks
     
    Last edited: Feb 24, 2020
  22. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    I replaced the search with a predefined list of GUIDs in v1.11.2b19 to fix long compilation with Asset Pipeline V2.

    You can use ListView and ListViewPaginator with ForcedPosition = OnCenter (or ScrollRect with ScrollRectPaginator).
    The example is Examples/ListView/ListViewImages/ListViewBanners scene.

    I replaced ForceScrollOnPage with ForcedPosition to ScrollRectPaginator and ListViewPaginator in v1.11.2b19.
    ForcedPosition can be:
    • None: replacement for the disabled ForceScrollOnPage
    • OnStart: replacement for the enabled ForceScrollOnPage is enabled, the right item can be partially visible
    • OnCenter: position item to the center so the left and right items can be partially visible
    • OnEnd: the left item can be partially visible
    Replaced
    DialogActions
    with
    IList<DialogButton>
    and added
    onCancel
    parameter to
    Show(..)
    method for the click on top right close button.

    New code:
    Code (CSharp):
    1.  
    2.         public void ShowDialog()
    3.         {
    4.             var actions = new DialogButton[]
    5.             {
    6.                 new DialogButton("Cancel Button", ButtonHandler, 1),
    7.                 new DialogButton("Main Button", ButtonHandler, 0),
    8.             };
    9.  
    10.             DialogTemplate.Clone().Show(
    11.                 title: "Dialog With Different Buttons",
    12.                 message: "Test",
    13.                 buttons: actions,
    14.                 focusButton: "Close",
    15.                 modal: true,
    16.                 modalColor: new Color(0, 0, 0, 0.8f),
    17.                 onCancel: ButtonHandler
    18.             );
    19.         }
    20.  
    21.         bool ButtonHandler(int button)
    22.         {
    23.             return true;
    24.         }
    Old code with
    DialogActions
    is supported.
     
    jGate99 likes this.
  23. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Thank you you are amazing :D
     
  24. morgansmolder

    morgansmolder

    Joined:
    Jul 20, 2019
    Posts:
    3
    Hello,

    Thanks for making this asset, I’ve enjoyed playing around with it these last two days.

    I have a small question if it’s not too much trouble. I am looking to implement a menu with two lists – one on the left-hand side displaying a list of items and an initially empty list on the right-hand side:
    111.png
    I want the user to be able to drag up to ten items to the right-hand list from the left-hand list, but disable further interactions after this threshold is met.

    I have looked through the documentation and I’m not certain what is the best way to do this. I see that I could write a class which implements the DropSupport interface and build my own behavior, but this seems a little convoluted for such a simple requirement.

    Is there a better approach supported by the current system which could be used to achieve this functionality?

    Thanks!
     
  25. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    The best way is to use
    CanReceiveDrop
    function to control the ListView drop.

    You need to create a derived class for the drop support if you use ListViewIcos or other standard widgets (otherwise changes will be lost with the future updates) or modify existing class if ListView created with widget generation.
    1. Change
      CanReceiveDrop
      function to virtual in file Scripts/Drag-and-Drop/ListViewCustomDropSupport.cs
      Code (CSharp):
      1.  public virtual bool CanReceiveDrop(TItem data, PointerEventData eventData)
    2. Create derived class or modify existing class with overrided
      CanReceiveDrop
      :
      Code (CSharp):
      1.     public class ListViewIconsDropSupportLimitedQuantity : ListViewIconsDropSupport
      2.     {
      3.         [SerializeField]
      4.         public int MaxQuantity = -1;// negative value to disable the quantity limit
      5.  
      6.         public override bool CanReceiveDrop(ListViewIconsItemDescription data, PointerEventData eventData)
      7.         {
      8.             // disable drop if quantity limit reached
      9.             if ((MaxQuantity >= 0) && (ListView.DataSource.Count >= MaxQuantity))
      10.             {
      11.                 return false;
      12.             }
      13.  
      14.             return base.CanReceiveDrop(data, eventData);
      15.         }
      16.     }
    3. Replace the drop support component on empty ListView with the new one if you created the derived class.
    4. Specify MaxQuantity for the new component.
     
    Last edited: Feb 29, 2020
    hopeful likes this.
  26. morgansmolder

    morgansmolder

    Joined:
    Jul 20, 2019
    Posts:
    3
    Thanks for the exceptionally speedy response! Sounds good, I'll implement this today.
     
  27. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Version 1.11.2 released

    Changelog:
    • added TracksView to create custom schedule or time-line widgets
    • added InputFieldAdapter to improve TextMesh Pro support
    • added ListComponentPool
    • added SplitButton
    • Dialog: added RectTransform content and Action onClose parameters to Show(…) method
    • Dialog: added OpenedDialogs property to get list of the opened dialog
    • Dialog: DefaultButton replaced with ButtonsTemplates and DialogActions now has option to specify button index for the button template
    • Dialog: type of the “buttons” parameter in the Show() method changed to IList<DialogButton>
    • Dialog: added “Func<int, bool> onCancel” parameter to the Show() method, called with -1 parameter when dialog closed with top right close button
    • DragListener: OnDragListener renamed to DragListener
    • DragSupport: added optional DragHandle property, you can use it drag ListView items by specified handle instead of the whole item
    • DragSupport: added StartDragEvent and EndDragEvent
    • EasyLayout: added ElementsRotate and ElementsRotationStart for Ellipse layout
    • ListView: improved navigation support
    • ListView: added optional parameter minVisiblePart to IsVisible() method
    • ListView: replaced old ListView with ListViewString
    • ListView: added Virtualization setting to disable Virtualization
    • ListViewDropSupport: added DropPosition parameter
    • ListViewPaginator: now use ListView.ScrollToAnimatedPosition instead of the own animation
    • Notify: fixed incorrect size and rotation of next notification if previous notification was closed during hide animation
    • Resizable: added AllowResize property to enable/disable resize without removing component
    • ScrollBlock: SetText() renamed to UpdateView()
    • ScrollRectPaginator: ForceScrollOnPage replaced with ForcedPosition to support different positions
     
    jGate99 likes this.
  28. Petskus

    Petskus

    Joined:
    Jan 29, 2019
    Posts:
    25
    Сan Shaders/UIFlare highlight only the opaque part of the image?
     
  29. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Yes, you need to create a copy of the shader and replace code in the pixel shader:
    Code (CSharp):
    1.                 half4 base_color = tex2D(_MainTex, IN.texcoord); // added
    2.                 half4 color = base_color * IN.color; // changed
    3.                 #if defined(UIWIDGETS_COLORSPACE_GAMMA) || defined(UNITY_COLORSPACE_GAMMA)
    4.                 color = lerp(_FlareColor, color, rate);
    5.                 #else
    6.                 color = lerp(LinearToGammaSpace4(_FlareColor), color, rate);
    7.                 color = GammaToLinearSpace4(color);
    8.                 #endif
    9.                 color.a = base_color.a; // added
     
    Petskus likes this.
  30. Petskus

    Petskus

    Joined:
    Jan 29, 2019
    Posts:
    25
    This version broke TileView with Fixed Size.
    EasyLayout setting of Container is MainAxes=Vertical and LayoutType=Compact. But at 1.11.2 elements became invisible.
    Change LayoutType to Staggered makes elements visible like as before upgrade. But after start MainAxis automaticly change to Horizontal and elements show only in single row. Set MainAxis to Vertical manually makes elements visible as before upgrade.

    1.11.2b14 worked fine.
     
    Last edited: Mar 6, 2020
  31. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Sorry, I cannot reproduce it.
    1. What Unity version are you use?
    2. Is TileView's direction horizontal?
    3. Please show screenshots of EasyLayout and ContentSizeFitter settings after the start
    4. Is this problem happens with Examples/TileView/TileView scene?
     
  32. Petskus

    Petskus

    Joined:
    Jan 29, 2019
    Posts:
    25
    1) 2019.2.20f1
    2) Vertical. In Horizontal direction the same.
     

    Attached Files:

  33. Petskus

    Petskus

    Joined:
    Jan 29, 2019
    Posts:
    25
     

    Attached Files:

  34. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Thanks, I reproduced the problem, it is a bug with disabled Virtualization.

    Fix:
    Replace code in UpdateLayout() in Scripts/ListView/ListViewType/ListViewTypeRectangle.cs.
    old code:
    Code (CSharp):
    1.                 if (Owner.LayoutBridge == null)
    2.                 {
    3.                     return;
    4.                 }
    new code:
    Code (CSharp):
    1.                 if ((Owner.LayoutBridge == null) || (!Owner.Virtualization))
    2.                 {
    3.                     Owner.LayoutBridge.SetFiller(0f, 0f);
    4.                     Owner.LayoutBridge.UpdateLayout();
    5.                     return;
    6.                 }
     
    Petskus likes this.
  35. Petskus

    Petskus

    Joined:
    Jan 29, 2019
    Posts:
    25
    Thanks. It's helped
     
  36. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Hi @ilih
    it looks like there is something heavy processing going on in project settings > New UI Widgets Section on Unity 2019.3 when we have to enable/disable TMPro support. At that tab, unity becomes super slow. I'm using Asset DB 2
    please investigate
    Thanks
     
  37. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    What exact Unity version are you use? It looks like it happens with only some 2019.3 versions.
     
    jGate99 likes this.
  38. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Looks like its not new ui widgets but Unity's own issue, sorry for misunderstanding
     
    ilih likes this.
  39. jGate99

    jGate99

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

    I have a dialog with one button and templateIndex = 0
    but i get button = 1 instead of 0 in handler? can you please check it.


    Secondly, can we avoid it totally templateIndex totally?
    because templateIndex will be button index in array so

    new DialogButton[]
    {
    new DialogButton("Main Button", ButtonHandler), //im 0 index
    new DialogButton("Cancel Button", ButtonHandler),// im 1 index

    };

    Thanks
     
  40. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    It is a bug.
    Replace code in CreateButtons() method in Dialog.cs
    old code:
    Code (CSharp):
    1.                 UnityAction callback = () =>
    2.                 {
    3.                     if (button.Action(index))
    4.                     {
    5.                         Hide();
    6.                     }
    7.                 };
    new code:
    Code (CSharp):
    1.                 var btn_index = index;
    2.                 UnityAction callback = () =>
    3.                 {
    4.                     if (button.Action(btn_index))
    5.                     {
    6.                         Hide();
    7.                     }
    8.                 };
    Unfortunately not, because of the high chance that buttons templates have only one button and Dialog.Show(...) called with more than one button.
    So if you call Show() with two buttons and specified only one button template, it will cause an error.
    And most importantly, this causes errors with all existing code, which worked fine before.
     
    Last edited: Mar 10, 2020
    jGate99 likes this.
  41. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Please do consider adding local functions in your code over time, at they perform better than lambda. I know you are targetting unity 5 where C#7 was not available, so what you can do is whenever you touch some class for bugs/adding feature just add local functions for modern unity version.
    This way wont be spending several weeks changing your code and at the same time slowly making your code better.

    Thanks

    Edit:
    When i say adding i mean, keep lambda for old unity, and local for new modern unity
     
    Last edited: Mar 10, 2020
  42. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    I have plans to replace lambdas, but I want to finish features that I am working on now first.
     
    jGate99 likes this.
  43. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    Sure, looks like New UI Widgets is getting more components on top of already massive list :), any hints?
     
  44. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    It is not a new widgets, just an automatic converter from default Unity text to TextMesh Pro for the separate widgets and whole scenes.
     
    jGate99 likes this.
  45. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    sounds great
     
  46. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
  47. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    A Resizable component is available, you can check the demo scene at Examples/Resizable/*.
    I'll think about scale and rotation.
     
    jGate99 likes this.
  48. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    thanks
     
  49. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,945
    @ilih, EasyLayout already has Flow Layout like properties, it already has a feature where inactive items take space, and you have already solved drag n drop on List view.
    So it'd be really great if you can provide an example which uses all of these for following situation.
    Thanks

    Capture.PNG

    Same is do able if i drag"It" (smallest item) to left or right
    So in current image where 2nd row is
    [Item 23][It][Itm]

    If i drag [It] to left then 2nd row become like this
    [It][Item 23][Itm]
     
  50. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,415
    Unfortunately, ListView drag-and-drop cannot be easily redone to EasyLayout drag-and-drop.
    I'll think about it, but I cannot say when it will be available.
    I want to finish TMPro converter first, then replace lambdas with local functions, Scale support for the Resizable component, Rotatable component.
     
    jGate99 likes this.