Search Unity

  1. Unity 2019.2 is now released.
    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:
    705
    I working on it.

    Try to add following lines in Combobox.cs, after line 207 [ listView.gameObject.SetActive(true); ]
    Code (CSharp):
    1.             var layout = listView.Container.GetComponent<EasyLayout.EasyLayout>();
    2.             if (layout!=null)
    3.             {
    4.                 layout.UpdateLayout();
    5.             }
    In development yet, plan to finish in this week.
     
    johanneskopf and RazaTech like this.
  2. johanneskopf

    johanneskopf

    Joined:
    Feb 16, 2015
    Posts:
    52
    Thank you!
    I'm looking forward to your next updates. :)
     
  3. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,036
    Does this Asset support Playmaker actions and Playmaker? It would be great if it does/did...
     
  4. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    169
    Waiting for End of this Week :cool:
     
  5. schragnasher

    schragnasher

    Joined:
    Oct 7, 2012
    Posts:
    117
    BINGO! That seems to have worked. Thanks!
     
  6. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    Version 1.4.1 available to download.

    No.
     
    johanneskopf likes this.
  7. schragnasher

    schragnasher

    Joined:
    Oct 7, 2012
    Posts:
    117
    Can you confirm if the combobox issue is a general problem or just an issue with how I use the control? Do I need to change how I use the control. Are the fixes included in 1.4.1? Thanks
     
  8. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    General problem, but happens randomly.

    No. 1.4.1 was submitted to AssetStore few days before I find way to fix it.
     
  9. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    Added support ListView with items of variable heights.
    Update will be available to download after AssetStore approval.
     
  10. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    169
    Thank you very much :)
    it Would be more then awsome if you can also provide tileview (which renderer only 10 items even when there is 1000 data items). That'd make it number one ui kit (Which it already is :))
    Can you please also share your plan, i mean what are you building now a days, what should we expect from future updates

    Thanks once again
     
  11. sumihiro

    sumihiro

    Joined:
    Jul 2, 2015
    Posts:
    2
    @ilih I got some errors. What's wrong?

    my code.
    Code (CSharp):
    1.         // get dialog instance by template name (name of existing GameObject with Dialog component).
    2.         var dialog = Dialog.Template("DialogTemplate");
    3.         // show dialog with following parametres
    4.         dialog.Show(
    5.             title: "Modal Dialog",
    6.             message: "Simple Modal Dialog.",
    7.             buttons: new DialogActions(){
    8.                 // Button name and Func<bool>, return true to close dialog, otherwise false
    9.                 {"Close", Dialog.Close},
    10.             },
    11.             focusButton: "Close",
    12.             modal: true,
    13.             modalColor: new Color(0, 0, 0, 0.8f)
    14.         );
    15.  
    errors.
    I use latest version (1.4.1) of your great library.
     
  12. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    DialogTemplate should be inside Canvas.

    Wrong, dialog will not be displayed and throw exception:


    Correct:
     
  13. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    Plans:
    • TreeView
    • ListView header with resizable columns
    • Drag&Drop
    • Resizable behaviour
    • TileView
     
    johanneskopf likes this.
  14. sumihiro

    sumihiro

    Joined:
    Jul 2, 2015
    Posts:
    2
    @ilih Thank you very much.
    I tried to add DialogTemplate to canvas, but i got same error.

    Can I download some demo project?
     
  15. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    You can use scene UIWidgets/UIWidgets SampleScene as example.

    Try to modify DraggableHandle.cs:
    1. Replace line 10
      Code (CSharp):
      1.     public class DraggableHandle : MonoBehaviour, IDragHandler, IInitializePotentialDragHandler {
    2. Add following code in line 25
    3. Code (CSharp):
      1.         public void OnInitializePotentialDrag(PointerEventData eventData)
      2.         {
      3.             canvasRect = Utilites.FindCanvas(transform) as RectTransform;
      4.             canvas = canvasRect.GetComponent<Canvas>();
      5.         }
    4. Remove lines 22 and 23
      Code (CSharp):
      1.             canvas = Utilites.FindCanvas(transform).GetComponent<Canvas>();
      2.             canvasRect = canvas.GetComponent<RectTransform>();
     
  16. David Wagg

    David Wagg

    Joined:
    Aug 5, 2013
    Posts:
    8
    Hi Ilya,

    I'm having trouble loading dynamic content into ListView (Unity 5.1.1, UIWidgets 1.4.1). If I load content from a button press, everything works as expected. But if I load from code (from MonoBehaviour Start() for example), then the scrollbar is not resized correctly.

    Loading from code (there are ten items):

    After button press a new list is loaded:


    I've attached a simple test project that demonstrates this problem. How can I get the scrollbar to resize properly when loading content from code?
     

    Attached Files:

  17. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    Replace line 807 in ListView.cs and line 721 in ListViewCustom.cs
    old line:
    Code (CSharp):
    1.                 layout.SetLayoutVertical();
    new line:
    Code (CSharp):
    1.                 layout.UpdateLayout();
     
  18. David Wagg

    David Wagg

    Joined:
    Aug 5, 2013
    Posts:
    8
    Thanks for the quick response, that works perfectly!
     
  19. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    Version 1.4.2 released.
    • Added support ListView with items of variable heights.
    • Bugfixes.
     
  20. SketchWork

    SketchWork

    Joined:
    Jul 6, 2012
    Posts:
    208
    Hi there,

    I'm too having problems with the dialogue box. I have the dialogue template inside the canvas gameobject, but when I call the dialog.Show method it is creating the clone outside the Canvas so it is not showing. Any ideas?

    Thanks, Justin
     
  21. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    Please try replace line 196 in Dialog.cs
    old code:
    Code (CSharp):
    1.             transform.SetParent(parent, false);
    new code:
    Code (CSharp):
    1.             if (parent!=null)
    2.             {
    3.                 transform.SetParent(parent, false);
    4.             }
     
  22. SketchWork

    SketchWork

    Joined:
    Jul 6, 2012
    Posts:
    208
    I found the problem. If you drop on the prefab component from your project folder it doesn't work correctly. If you add it from the menu GameObject -> UI -> Dialog Template is then works correctly. maybe you should add this to your documentation that you should never add the component by drag dropping the prefab.

    Thanks for your help, Justin
     
  23. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    How to use Dialog prefab:
    • Add prefab to templates
    • Show dialog from template and specify canvas to use
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4. using UIWidgets;
    5.  
    6. public class TestDialogPrefab : MonoBehaviour {
    7.     public Dialog SampleDialog;
    8.     public Canvas CanvasToUse;
    9.  
    10.     public void ShowDialog()
    11.     {
    12.         // Add template if not exists
    13.         if (!Dialog.Templates.Exists("dialog prefab"))
    14.         {
    15.             Dialog.Templates.Add("dialog prefab", SampleDialog);
    16.         }
    17.  
    18.         Dialog.Template("dialog prefab").Show(
    19.             title: "Simple Dialog",
    20.             message: "Simple dialog with only close button.",
    21.             buttons: new DialogActions(){
    22.                 {"Close", Dialog.Close},
    23.             },
    24.             focusButton: "Close",
    25.  
    26.             position: null,
    27.             icon: null,
    28.             modal: false,
    29.             modalSprite: null,
    30.             modalColor: null,
    31.  
    32.             canvas: CanvasToUse
    33.         );
    34.     }
    35. }
    36.  
    Or you can instantiate prefab and specify canvas to instance, then you don't need to specify canvas in Show() call.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4. using UIWidgets;
    5.  
    6. public class TestDialog : MonoBehaviour {
    7.     public Dialog SampleDialog;
    8.     public Canvas CanvasToUse;
    9.  
    10.     public void ShowDialog()
    11.     {
    12.         // Add template if not exists
    13.         if (!Dialog.Templates.Exists("new dialog"))
    14.         {
    15.             // Instatiate
    16.             var dialog = Instantiate(SampleDialog) as Dialog;
    17.             // Specify canvas
    18.             dialog.transform.SetParent(CanvasToUse.transform);
    19.          
    20.             // Add to templates
    21.             Dialog.Templates.Add("new dialog", dialog);
    22.         }
    23.  
    24.         Dialog.Template("new dialog").Show(
    25.             title: "Simple Dialog",
    26.             message: "Simple dialog with only close button.",
    27.             buttons: new DialogActions(){
    28.                 {"Close", Dialog.Close},
    29.             },
    30.             focusButton: "Close"
    31.         );
    32.     }
    33. }
     
    Last edited: Jul 14, 2015
  24. SketchWork

    SketchWork

    Joined:
    Jul 6, 2012
    Posts:
    208
    Ahh, ok. Thanks. Maybe it should be made more clear in the documentation.

    One other issue I have experienced with the Dialog and Templates. If you open a modal dialog in the Start() of a scene and progress to a different scene, when you come back to the original scene again you get an error:

    1) Open Scene 1
    2) Call Template Dialog Show in Start()
    3) Close dialog and load Scene 2
    4) Load Scene 1 again
    5) When it tries to call the show in the Start() method you get this error:

     
  25. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    Fix:
    Add following lines in ModalHelper.cs, line 42
    Code (CSharp):
    1.         void OnDestroy()
    2.         {
    3.             Templates.Delete(key);
    4.         }
     
  26. SketchWork

    SketchWork

    Joined:
    Jul 6, 2012
    Posts:
    208
    Excellent. That fixed it.
     
  27. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    I got a warning in 5.1.1f1 when import your asset:

    Assets/UIWidgets/Standart Assets/OnDragKeepSelected.cs(19,87): warning CS0618: `UnityEngine.EventSystems.EventSystem.lastSelectedGameObject' is obsolete: `lastSelectedGameObject is no longer supported'
     
  28. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    For now, remove line 19 from OnDragKeepSelected.cs
     
  29. TonyT

    TonyT

    Joined:
    Mar 17, 2014
    Posts:
    20
    Hi

    With listview, with multiple selection on, is there a way to Shift-Select? You select one and then shift select one several down the list and all the elements in between are selected.

    I think I can code it up myself but I just wanted to check if there was something already inbuilt that I missed.

    Thanks
     
  30. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    It not available in current version, but you can add it with following code.
    Replace Toggle function in ListViewBase.cs, lines 527-534:
    Code (CSharp):
    1.         /// <summary>
    2.         /// Toggle the specified item.
    3.         /// </summary>
    4.         /// <param name="item">Item.</param>
    5.         void Toggle(ListViewItem item)
    6.         {
    7.             var shift_pressed =  Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
    8.             var have_selected = selectedIndicies.Count > 0;
    9.             if (Multiple && shift_pressed && have_selected && selectedIndicies[0]!=item.Index)
    10.             {
    11.                 // deselect all items except first
    12.                 selectedIndicies.GetRange(1, selectedIndicies.Count - 1).ForEach(Deselect);
    13.  
    14.                 // find min and max indicies
    15.                 var min = Math.Min(selectedIndicies[0], item.Index);
    16.                 var max = Math.Max(selectedIndicies[0], item.Index);
    17.                 // select items from min to max
    18.                 Enumerable.Range(min, max - min + 1).ForEach(Select);
    19.                 return ;
    20.             }
    21.  
    22.             Toggle(item.Index);
    23.         }
     
    Last edited: Jul 23, 2015
  31. TonyT

    TonyT

    Joined:
    Mar 17, 2014
    Posts:
    20
    Thanks very much for that!!!

    Great support!! (Actually brilliant support)

    Thanks again

    Tony
     
  32. sanpats

    sanpats

    Joined:
    Aug 24, 2011
    Posts:
    343
    Any plan to add support a new built-in 5.2 beta drop down functionality, and 2D Rect Mask?
     
  33. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    I don't have access to beta, maybe after release.
     
    Last edited: Jul 24, 2015
  34. Reiswolf

    Reiswolf

    Joined:
    Jul 26, 2015
    Posts:
    1
    Hey ilih, thanks for your great work.
    My question is, how can i get the last index selected in a listview?

    thanks
     
  35. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    Code (CSharp):
    1. listView.SelectedIndex
    or
    Code (CSharp):
    1. listView.SelectedIndicies[listView.SelectedIndicies.Count - 1]
    If you need maximum selected index you can use this
    Code (CSharp):
    1. var max_index = Enumerable.Max(listView.SelectedIndicies);
     
  36. kendev

    kendev

    Joined:
    Aug 9, 2015
    Posts:
    9
    Hi ilih,

    I’m using a ListViewIcons and it works great when running on my Mac. When I build it for the Android platform however, the item selection behaves erratically. Sometimes I have to double-tap to get an item selected and often it only exhibits the MouseOver state without repeated tapping.

    Are there any specific configuration settings or requirements to get proper behavior when running under Android? I noticed the same behavior when I installed the UIWidgets-v.1.3.1.apk demo app.

    Thanks,

    Ken
     
  37. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    Please try
    "EventSystem" → "Standalone Input Manager" → disable "Allow Activation On Mobile Device"
     
  38. kendev

    kendev

    Joined:
    Aug 9, 2015
    Posts:
    9
    Hi ilih,

    I changed the settings on the Standalone Input Module as well as the Touch Input Module and observed somewhat different behavior when running under Android - the intermittent selection behavior of the ListView appears to be a Unity issue. I’m currently using the Standalone Input Module with ‘Allow Activation On Mobile Device’ set to On, and have deactivated the Touch Input Module.

    I’ll continue to research this problem as I want to use the ListViewIcons in my Android app and eventually the iOS app - I wonder if this is an issue when running under iOS? I would appreciate any feedback on how to get this widget working under Android as great as it does under OSX.

    Thanks,

    Ken
     
  39. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    I did some checks, and suppose this configuration will be best. (Still "Input Actions Per Second" can be 10 or lower)


    How Input Modules Works:
    • "Standalone", "Touch", "Mobile Device" does not have anything with build or OS.
    • Standalone Input Module used when Input.mousePresent or forced with "Allow Activation On ..." checkbox.
    • Touch Input Module used when Input.touchSupported or forced with "Allow Activation On ..." checkbox.
    • Mouse, keyboard and gamepad events will process with Standalone Input Module.
    • Touch events will process with Touch Input Module.
    • Every frame Event System check what Input Module will be used in current frame: first module that can process input events in current frame or have "Allow Activation On ..." enabled.
    If "Allow Activation On ..." disabled for all Input Modules, then all works fine: Standalone Input Module process mouse and keyboard events, Touch Input Module process touch events.
    Problem happended when Standalone Input Module forced to process touch events with "Allow Activation On ..." - it's try to imitate PointerEnter and PointerExit events (mouseover and mouseout) with touch events, and it's works bad.

    I don't have any iOS devices, so I cannot check how it works, but it should not be different from Android.
     
    Last edited: Aug 11, 2015
  40. kendev

    kendev

    Joined:
    Aug 9, 2015
    Posts:
    9
    Hi ilih,

    Thanks for the configuration info - I tried these settings and still get similar behavior. The Unity forums suggest that the Standalone and Touch Input Modules can be very problematic and there doesn’t seem to be a clear or consistent fix in all cases.

    I may be doing something wrong of course, but I get the same problematic behavior when using the UIWidgets-v.1.3.1.apk demo app. My current testing uses two different Samsung smartphones with Android version 4.4.2 and Android version 4.3. I’m using the latest version of Unity 5.1.

    More behavior details: tapping on a ListView item does not result in consistent behavior. Much of the time, the item will only highlight on the first tap, and a second tap will select the item. Much of the time it doesn’t respond until multiple taps are applied. Some of the time it works as expected. This is also true for the buttons.

    I have avoided digging into any code for a solution. In one Unity forum post, the user discovered that he had to inactivate all of the Touch Input Modules in all of the app screens to get the proper behavior on the one screen of interest. This is a Unity issue.

    Your widgets are great and I want to use them in my app for Android and iOS. If and when I ‘discover’ a fix for my particular case, I’ll post the results here. In the meantime, I would welcome any feedback on this issue, even if it points out that I’m doing something obviously wrong.

    Thanks again.

    Ken
     
  41. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    169
    Hi
    I m making list with variable height but scrolling is creating problem ,
    Calculate height function is giving same height for all items,
    and why does preferredHeight give "0"..?

    can you plz send some example how variable height list view works (Sceen , demo)
     

    Attached Files:

    • 1.png
      1.png
      File size:
      15.5 KB
      Views:
      488
    • 1png.png
      1png.png
      File size:
      46.9 KB
      Views:
      407
  42. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    Check Line Spacing and Scale in Name and Text gameobjects. It should be more than 0.

    1. Create functions to set data to component, without it height calculation can't work correctly.
      ListViewVariableHeight.cs
      Code (CSharp):
      1.     public class ListViewVariableHeight : ListViewCustomHeight<ListViewVariableHeightComponent,ListViewVariableHeightItemDescription> {
      2.         protected override void SetData(ListViewVariableHeightComponent component, ListViewVariableHeightItemDescription item)
      3.         {
      4.             component.SetData(item);
      5.         }
      6.        ...
      ListViewVariableHeightComponent.cs
      Code (CSharp):
      1.     public class ListViewVariableHeightComponent : ListViewItem, IListViewItemHeight {
      2.         [SerializeField]
      3.         public Text Name;
      4.  
      5.         [SerializeField]
      6.         public Text Text;
      7.  
      8.         public void SetData(ListViewVariableHeightItemDescription item)
      9.         {
      10.             Name.text = item.Name;
      11.             Text.text = item.Text.Replace("\\n", "\n");
      12.         }
      13.        ...
    2. DefaultItem settings
      ListViewVariableHeightComponent
      Easy Layout - provide width and height to Content Size Fitter
      Content Size Fitter with Vertical Fit = Preferred Size - change height of item when its contents changed
      Layout Element with setted Preffered Height - provide minimal item height.
    3. Name and Text settings
      Both should have Content Size Fitter with Vertical Fit = Preferred Size
      Also check that Line Spacing more than 0.

    4. Create height calculation function
      Code (CSharp):
      1.     public class ListViewVariableHeightComponent : ListViewItem, IListViewItemHeight {
      2.         ...
      3.         public float Height {
      4.             get {
      5.                 return CalculateHeight();
      6.             }
      7.         }
      8.        
      9.         float CalculateHeight()
      10.         {
      11.             // Default height values taken from inspector after steps 3 and 4
      12.             float default_total_height = 63;
      13.             float default_name_height = 21;
      14.             float default_text_height = 17;
      15.  
      16.             var base_height = default_total_height - default_name_height - default_text_height;
      17.  
      18.             return base_height + Name.preferredHeight + Text.preferredHeight;
      19.         }
      20.     }
     
  43. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    169
    hi
    you have used Easylayout in list view in your example,
    and it is not responsive , if i use unity horizontal layout then it's automatically arrange anchors and make it responsive ,
    tell me what should i use Easylayout or unity layout components ,
     
  44. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    169
    i have followed your steps but still having problems problems.png
     
  45. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    For ListView Container you should use EasyLayout. For DefaultItem you can use any layout, but GameObjects under Unity Layout in some cases does not provide correct information about sizes.

    Please show me how looks DefaultItem in Scene window and Name or Text in Inspector window.

    Fix for too many cloned objects:
    ListViewCustom.cs, replace line 370
    old line:
    Code (CSharp):
    1. var preffered_height = LayoutUtility.GetPreferredSize(rect, 1);
    new line:
    Code (CSharp):
    1. var preffered_height = rect.GetComponents<ILayoutElement>().Select(x => Math.Max(x.minHeight, x.preferredHeight)).Max();
     
  46. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    169
    kindly can you send me a working example(project) ....
    and can you make it compatible with unity layout system..?
     

    Attached Files:

    Last edited: Aug 19, 2015
  47. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    I've sent you a PM, check it.
     
  48. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    169
    CalculateHeight() is not being called , can you tell where is problem ?
     
  49. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    705
    Please make sure that component you use in DefaultItem and component that you check are same component.

    Also try check it with debugger:
    Monodevelop
    Run -> Attach to process, double click to "Unity Editor (Unity)"

    Set breakpoint in ListViewCustomHeight.cs:GetItemHeight in SetData call

    Press Play in Unity.
    Toggle to MonoDevelop.
    Press Step Into (F11) - you should be in same component that you check.
    .
    Press Step Over (F10) few times until you return back to ListViewCustomHeight.cs
    Check height value.
     
  50. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    169
    Pleas check this pkg what i m doing wrong with list view variable height :(
     

    Attached Files: