Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

New UI Widgets

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

  1. dagraca

    dagraca

    Joined:
    Jun 28, 2016
    Posts:
    11
    Thanks a lot
     
  2. cocopoil

    cocopoil

    Joined:
    Nov 24, 2016
    Posts:
    1
  3. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    Unfortunately, I do not have VR device to check it, but all widgets use Image, RawImage, and Text (all of them supported by Curved UI) so should work fine.
    Exceptions are TreeGraph and Connectors because they use custom Graphic component but should be easy to fix them to work with Curved UI.
     
    cocopoil likes this.
  4. dagraca

    dagraca

    Joined:
    Jun 28, 2016
    Posts:
    11
    Hello
    I ve got a TreeView with the multiselect option enabled (see image)

    what I d like to do is :
    in the case of multiselected items, if the user click on one Eye toggle, it should send the same click event on every others selected item.
    is there any way to do it ?
    upload_2018-10-25_11-49-7.png
     
  5. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    You can add a callback on Eye click to process all selected nodes:
    Code (CSharp):
    1.  
    2. namespace UIWidgets.Examples
    3. {
    4.     using UIWidgets;
    5.     using UnityEngine;
    6.  
    7.     public class ProcessEyeClick : MonoBehaviour
    8.     {
    9.         [SerializeField]
    10.         public TreeView Tree;
    11.  
    12.         public void ProcessSelectedNodes()
    13.         {
    14.             Tree.SelectedNodes.ForEach(x =>
    15.             {
    16.                 // do something with selected node
    17.                 Debug.Log(x.Item.Name);
    18.  
    19.                 var component = Tree.GetItemComponent(x.Index);
    20.                 if (component != null) // not visible component will be null
    21.                 {
    22.                     // do something with component
    23.                     component.ToggleEye();
    24.                     Debug.Log(component);
    25.                 }
    26.             });
    27.         }
    28.     }
    29. }
    "ProcessSelectedNodes()" should be attached to DefaultItem.Eye.
     
  6. dagraca

    dagraca

    Joined:
    Jun 28, 2016
    Posts:
    11
    thank you
     
  7. Eidoboy

    Eidoboy

    Joined:
    Jul 3, 2012
    Posts:
    24
    Hi, any news about the stable release?

     
  8. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    Released. Will be available in Asset Store after approving.



    Important things:
    • Widget Generation
    • Styles
    • TextMesh Pro support and Data Bind support enabled with menu "Project Settings / UIWidgets / Enable <package> support"

    Changelog:
    • Added styles support (Styles folder, new styles can be created from context menu "Create / UIWidget - Style")
    • Added widget generation (context menu "Create / UIWidget - Widgets" on file with item class definition)
    • Added DateTime, Time24 and Time12 widgets
    • Added DateTimePicker and TimePicker widgets
    • Added ColorPickerRangeHSV widget
    • Added ColorsList widget to display list of the selected colors, should be used with ColorPicker or ColorPickerRange
    • Added "Data Bind for Unity" support (requires Unity 5.6 or later)
    • Added base ListView Picker class for the custom ListView
    • Added base TreeView Picker class for the custom TreeView
    • Added base drop support class for the custom TreeView
    • Added base drop support class for the custom TreeView node
    • Added assembly definitions
    • Improvement: Drag can be canceled with Cancel button
    • Accordion: added AllItemsCanBeClosed option
    • Autocomplete: added GetInputFieldText() function
    • Calendar: added DateMin and DateMax properties
    • Calendar: added currentDateAsDefault option
    • ColorPicker: added Hex block
    • ColorPicker: added new palette mode HSVCircle
    • ColorPickerRange: DefaultShader replaced with DefaultShaderHorizontal and DefaultShaderVertical
    • Connectors: now works correctly with "Screen Space - Camera"
    • EasyLayout: reduced memory allocations
    • EasyLayout: EasyLayout namespace renamed to EasyLayoutNS to avoid problems with Unity 2018.2 and later
    • Interfaces: IItemWidth, IItemHeight, IListViewItemHeight, IListViewItemWidth not used anymore
    • ListView: added CenterTheItems property
    • ListView: added overridable functions CanBeSelected() and CanBeDeselected()
    • ListView: added LoopedList option
    • ListView: added Interactable option
    • ListView: added IsTable option (required to valid stylization)
    • ListView and TileView: ListViewCustomWidth, ListViewCustomHeight, TileViewCustom and TileViewCustomSize replaced with ListViewCustom with List Type option
    • ListViewCustomWidth: TItem now does not require IItemWidth implementation
    • ListViewCustomHeight: TItem now does not require IItemHeight implementation
    • ListViewDropIndicator: added styles support
    • ResizableHeader: fixed resize on touch devices
    • Sidebar: added OnOpeningStarted and OnClosingStarted, called when appropriated animation started
    • other: prefabs in "Sample Assets" folder replaced with scenes
    • other: "Standart Assets" folder renamed to "Scripts"
    • other: "Sample Assets" folder renamed to "Examples"
    • other: removed ListViewGameObjects prefab
    • other: removed outdated prefabs and sprites
    • other: namespace "UIWidgetsSamples" renamed to "UIWidget.Examples"
     
    Last edited: Nov 2, 2018
    zyzyx, Eidoboy and hopeful like this.
  9. Eidoboy

    Eidoboy

    Joined:
    Jul 3, 2012
    Posts:
    24
    It seems that the version for Unity 2018.2.4 has a 0 size package
     
  10. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    Sorry, fixed.
    Again made a typo in a filename.
     
    Eidoboy likes this.
  11. dagraca

    dagraca

    Joined:
    Jun 28, 2016
    Posts:
    11
    Hello
    I m on 2018.2.14f1 using the new UIwidget.
    Running SampleScene
    the treeview sample is not working.
    any ideas ?
     
  12. dagraca

    dagraca

    Joined:
    Jun 28, 2016
    Posts:
    11
    hi again
    sorry to be a pain :) but i m using uiwidget a lot for your great treeview...

    I tried to use treeview with textmeshpro and i ve got this :


    upload_2018-11-1_16-15-22.png
     
  13. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    It's an error in v1.10.0f1 and fixed in v1.10.0f2 - TestTreeView component has attached the wrong TreeView gameobject (TreeViewWithColumns instead TreeView)

    Are you enable TextMesh Pro support from the menu? Or just import package?
    If you import package you need to enable support from the menu or add "UIWIDGETS_TMPRO_SUPPORT" in Player Settings to "Scripting Define Symbols"

     
  14. dagraca

    dagraca

    Joined:
    Jun 28, 2016
    Posts:
    11
    I installed 1.10f2 and still error with Treeview with textmesh pro.

    if you use right click and add treeview like this :
    upload_2018-11-1_17-34-4.png

    you ll get the wrong treeview :
    upload_2018-11-1_17-38-1.png
     

    Attached Files:

  15. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    Please try to do the following thing:
    • open TreeViewComponentTMPro.cs and add a line
      public int a;
      after the line "public TextMeshProUGUI TextTMPro;"
    • then wait until Unity recompile scripts
    • and try to create TreeView from the menu again - now it's should work
    • now the line
      public int a;
      can be deleted
    I made some checks and look like Unity is some cases does not recompile scripts until they directly edited.
     
  16. dagraca

    dagraca

    Joined:
    Jun 28, 2016
    Posts:
    11
    yep it works.
    all the links were gone. I filled them easily.
    but when i click on run i ve got this upload_2018-11-1_18-53-28.png

    it seems there is no probleme without textmesh pro
     
  17. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    Probably create widgets from the menu will be faster - after fixing the error links should be correct, but if links are broken better reimport package.

    There is TreeView (or ListView) with unspecified DefaultItem, click on error should select this gameobject in hierarchy window.
     
  18. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    52
    @ilih please povide a new buiild that works with Unity 2018.3 beta
    I'm unable to enable support for TMPro due to new unified project settings.
     
  19. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    Probably you just miss it, with 2018.3 beta becomes two "Project Settings" menu, use the second to enable TMPro support.
     
    helloworldgames likes this.
  20. taptpci

    taptpci

    Joined:
    Jan 31, 2018
    Posts:
    4
    @ilih, hello. I see that ListViews can work with unevenly sized content. Do they have the ability to act like the OSX dock, with its "tsunami" effect? If not, is this something you'd plan to implement?
     
  21. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    Sorry, I don't have any experience with OS X.
    Please explain more: is it such tsunami effect? When item size is changed with distance to cursor?
    I can try to reproduce it.
     
  22. taptpci

    taptpci

    Joined:
    Jan 31, 2018
    Posts:
    4
    @ilih, yes that is exactly the effect. Thank you for your effort!
     
  23. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
  24. taptpci

    taptpci

    Joined:
    Jan 31, 2018
    Posts:
    4
    Wow, thank you for being so responsive! I will give this a try tonight.
     
  25. Eidoboy

    Eidoboy

    Joined:
    Jul 3, 2012
    Posts:
    24
    I've a problem with ListView in 1.10. I have some list under some canvases that start inactive, and those lists don't seem to initialize correctly, most of the time the problem is in visualization (the viewport appears smaller than it should be) and also if I add some objects by code, while still inactive, I can have an ArgumentOutOfRangeException. Is something changed from 1.9?
     
  26. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    No, there should be no changes that cause such behavior.
    Viewport appears smaller because it's size changed or his own scale or one of the parents gameobjects scale are changed?

    Please show full stack trace for ArgumentOutOfRangeException.
     
  27. taptpci

    taptpci

    Joined:
    Jan 31, 2018
    Posts:
    4
    This is mostly really nice, though It does have one problem so far. If you notice, the last item(s) on the list might never be able to scroll up into view because the tsunami seems to shift items downward no matter where in the visible rect they are. If it were possible to shift items above the pointer upwards, and items below the pointer downwards, it would probably be correct.

    That said, I understand the difficulty of that in a scrollable list view. This effect might be best for a static, non-scrolling list with a known number of entries.
     
  28. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    I'll try to add scroll compensation for tsunami effect.
     
  29. AmRafay1

    AmRafay1

    Joined:
    Oct 22, 2013
    Posts:
    671
    @ilih Can you please add a "selected" color in toggle? currently ugui toggle has normal, highlighted, pressed and disabled but not selected. SelectableHelper could also have that feature too.
    Thanks
     
  30. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    How "selected" color should be used? If you want to change color when Toggle is On state then you change checkmark image with required color.
     
  31. AmRafay1

    AmRafay1

    Joined:
    Oct 22, 2013
    Posts:
    671
    For example, this is toggle, world is selected but friends is not
    when i say toggle, i mean using ugui's toggle as radio buttons

    Update 2#
    If you just add it "SelectableHelper" , so normal will be for a radio which is not selected but "selected" will be used for radio which is actually selected
     

    Attached Files:

    Last edited: Nov 9, 2018
  32. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    I added scroll compensation, please try v1.10.1b4
     
  33. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    I'll think about it, not sure if this possible.
     
    AmRafay1 likes this.
  34. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    1. Toggles will work as radio button if you set same Toggle Group.
    2. To make text selected you need to duplicate text and change text color then set original text as Toggle.TargetGraphic and selected text as Toggle.Graphic instead checkmark.
     
  35. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    v1.10.1 released

    Changelog:
    • ListView: added ScrollTo(item) and ScrollToAnimated(item) functions
    • Paginator: added StopAnimation() function
    • ListViewPaginator: fixed toggle direction problem
    • TreeView: added ScrollTo(node) and ScrollToAnimated(node) functions
    • TreeView: added FindNode() function
    • TreeView: now ScrollTo(..) and ScrollToAnimated(…) correctly work with node indentation
    • Widget Generation: added interface types support
    • Widget Generation: fixed property support
     
    hopeful likes this.
  36. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,026
    I get following errors when I show ColorPicker. Did I set up something wrong?


    Trying to remove PaletteCursor (UnityEngine.UI.Image) from rebuild list while we are already inside a rebuild loop. This is not supported.
    UnityEngine.GameObject:SetActive(GameObject, Boolean)
    UIWidgets.ColorPickerHSVPalette:UpdateView() (at Assets/New UI Widgets/Scripts/ColorPicker/ColorPickerHSVPalette.cs:497)
    UnityEngine.Events.UnityEvent:Invoke()
    UIWidgets.ResizeListener:OnRectTransformDimensionsChange() (at Assets/New UI Widgets/Scripts/Utilites/ResizeListener.cs:55)
    UnityEngine.Canvas:SendWillRenderCanvases()

    Trying to remove Palette (UnityEngine.UI.Image) from rebuild list while we are already inside a rebuild loop. This is not supported.
     
  37. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    What Unity version you use?

    Update:
    It's not a critical error and you can ignore it.
    The problem caused by an old fix for Unity 5.2 (sprites was not updated after shader variable changed and fix disable and enable objects back to update sprites) and later versions and not needed at least since Unity 2017.1.

    Here is fix:
    Replace lines in files ColorPicker/ColorPicker*.cs
    old line:
    #if UNITY_5_2 || UNITY_5_3 || UNITY_5_3_OR_NEWER

    new line:
    #if (UNITY_5_2 || UNITY_5_3 || UNITY_5_3_OR_NEWER) && !UNITY_2017_1_OR_NEWER

    Or update to v1.10.2b3
     
    Last edited: Nov 20, 2018
  38. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,144
    Any infinite scroll or something that can handle a lot of items more efficiently, and provides good system for adding items into it... and maybe removing from certain indexes?
     
  39. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    Infinite scroll not possible, but you can make ListView looped.

    ListView creates game objects to display only visible items, so it works very efficiently unless items have variable size like strings with different lines count. Because the sizes of items are precalculated it can became a problem with long initialization for huge lists.

    ListView.DataSource have the same interface as List<T>.
     
  40. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,144

    aah shame... yeh I have strings that would be going into these where the line count will definitely vary a bit :(

    I found https://github.com/qiankanglai/LoopScrollRect which looked really good for an example .. but actually using it in a project is just a mess that would need taking apart as there is no real api for adding things, just a good demo project really. Maybe you could implement similar with better api :)
     
  41. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    I plan to add an option to disable precalculate items sizes for such lists with the next update.
    Calculations will use default size until item displayed then size will be replaced with actual item size.
     
  42. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,026
    beta works fine.
     
  43. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    52
    @ilih,
    how can i use UnityEventTools.AddBoolPersistentListener with switch component as editor script so i dont have to manually drag n drop?
    thanks
     
  44. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    Something like this:
    Code (CSharp):
    1.            // required data
    2.             var target = your_object;
    3.             var method_name = "SomeMethod";
    4.             var listener = switch_object.OnValueChanged;
    5.  
    6.             // adding listener
    7.             var method = UnityEventBase.GetValidMethodInfo(target, method_name, Type.EmptyTypes);
    8.             var method_delegate = Delegate.CreateDelegate(typeof(UnityAction), target, method) as UnityAction;
    9.             UnityEventTools.AddPersistentListener(listener, method_delegate);
     
    helloworldgames likes this.
  45. helloworldgames

    helloworldgames

    Joined:
    Mar 16, 2017
    Posts:
    52
    This is using reflection, cant i use a non-reflection method so i dont have to provide string based method, something like this?

    Code (CSharp):
    1. public static void AddPersistentListener(this Button button, UnityAction onClickHandler)
    2.         {
    3.             UnityEventTools.AddPersistentListener(button.onClick, onClickHandler);
    4.      
    5.         }

    Ideally i want to send switch as sender like this using 2nd approach
    https://stackoverflow.com/a/41027533/201988

    onValueChanged(Switch sender);
     
    Last edited: Nov 30, 2018
  46. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    Yes.
    Code (CSharp):
    1.         void AddSwitchListener(Switch target, UnityAction<Switch> listener)
    2.         {
    3.             UnityEventTools.AddObjectPersistentListener<Switch>(target.OnValueChanged, listener, target);
    4.         }
    5.  
    6.         public void TestAttach()
    7.         {
    8.             AddSwitchListener(TargetSwitch, TestSwitch);
    9.         }
    10.  
    11.         public void TestSwitch(Switch sender)
    12.         {
    13.             Debug.Log("Switch value: " + sender.IsOn);
    14.         }
     
    Last edited: Nov 30, 2018
    helloworldgames likes this.
  47. AmRafay1

    AmRafay1

    Joined:
    Oct 22, 2013
    Posts:
    671
    @ilih,
    Hi there,
    I liked LayoutSwitcher and how it works, However i'm unable to meet my objective due to hard coded nature of aspect ratios.

    What i prefer is following workflow:

    - I add layout switcher.
    - I add aspect ratios myself, in my case 2 (portrait and landscape)
    - i save the objects and thats it.


    ==

    another workflow is

    I added 3 aspect ratios or "ranges"
    3:4
    9:16
    16:9

    where 3:4 will be used if aspect is either 3:4 or less than it
    16:9 will be used if aspect is either 16:9 or greater than it
    anything else appear in 9:16

    ====

    These workflows will make it layout switcher very extensible. If you could add those features, it'd be great.
    Thanks
     
  48. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    Please explain how are you compare aspect ratios?
    3:4 = 0.75
    9:16 = 0.5625
    16:9 = 1.78

    And 3:4 are real? Maybe 4:3 - it's a TV standard and 16:9 HDTV standard.

    I can add an option to choose an appropriate aspect ratio with a custom function instead of hardcoded.
     
    Last edited: Dec 3, 2018
  49. AmRafay1

    AmRafay1

    Joined:
    Oct 22, 2013
    Posts:
    671
    So i have a portrait game for iOS n Android, but it will also be playable on desktop (as landscape)

    So what i want is that on mobile aspect ratios (portrait)
    such as (3:4 as portrait ipad pro etc) which is kind of square have different rectransform settings
    and on (9:16 as portrait) which is quite long rectangular shape (iPhoneX) i will have different rectransform setting

    but on desktop 16:9 (landscape) ill have different values.

    importnat thing is i myself able to add aspect ratio values 9:16 portrait and 16:9 landscape and layout switcher automatically falls between min, middle and max like bootstrap.

    Thanks
     
  50. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    583
    I added "LayoutSelector" field which selects the required layout in v1.10.2b7:
    Code (CSharp):
    1. namespace UIWidgets.Examples
    2. {
    3.     using System.Collections.Generic;
    4.     using System.Linq;
    5.     using UIWidgets;
    6.     using UnityEngine;
    7.  
    8.     /// <summary>
    9.     /// Test layout switcher.
    10.     /// </summary>
    11.     public class TestLayoutSwitcher : MonoBehaviour
    12.     {
    13.         [SerializeField]
    14.         public LayoutSwitcher Switcher;
    15.  
    16.         public void Start()
    17.         {
    18.             Switcher.LayoutSelector = Selector;
    19.         }
    20.  
    21.         UILayout Selector(List<UILayout> layouts, float displaySize, float aspectRatio)
    22.         {
    23.             if (aspectRatio < 1f) // portrait mode
    24.             {
    25.                 // select all portrait layouts greater then current aspect ratio and then select layout with lowest aspect ratio
    26.                 var layout = layouts.Where(x => x.AspectRatioFloat >= aspectRatio).OrderBy(x => x.AspectRatioFloat).FirstOrDefault();
    27.                 if (layout != null)
    28.                 {
    29.                     return layout;
    30.                 }
    31.             }
    32.  
    33.             // landscape mode
    34.             return layouts.Where(x => x.AspectRatioFloat >= 1f).OrderBy(x => Mathf.Abs(aspectRatio - x.AspectRatioFloat)).FirstOrDefault();
    35.         }
    36.     }
    37. }
     
    AmRafay1 likes this.