Search Unity

New UI Widgets

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

  1. TigerHix

    TigerHix

    Joined:
    Oct 20, 2015
    Posts:
    19
    Thanks! That solved the problem.

    Though, there's another StackOverflowException I am currently having modified some properties on the GameObjects inside the ListViewHeight prefab. This error happens when I scroll beyond the bottom.


    StackOverflowException
    UnityEngine.RectTransform.get_anchoredPosition ()
    UIWidgets.ListView.GetScrollValue () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1314)
    UIWidgets.ListViewHeight.GetFirstVisibleIndex (Boolean strict) (at Assets/New UI Widgets/Scripts/ListView/ListViewHeight.cs:469)
    UIWidgets.ListView.CalculateVisibilityData () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1531)
    UIWidgets.ListView.ScrollUpdate () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1455)
    UIWidgets.ListView.SetScrollValue (Single value) (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1304)
    UIWidgets.ListView.ValidateScrollValue () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1641)
    UIWidgets.ListView.ScrollUpdate () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1459)
    UIWidgets.ListView.SetScrollValue (Single value) (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1304)
    UIWidgets.ListView.ValidateScrollValue () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1641)
    UIWidgets.ListView.ScrollUpdate () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1459)
    UIWidgets.ListView.SetScrollValue (Single value) (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1304)
    UIWidgets.ListView.ValidateScrollValue () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1641)
    UIWidgets.ListView.ScrollUpdate () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1459)
    UIWidgets.ListView.SetScrollValue (Single value) (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1304)
    UIWidgets.ListView.ValidateScrollValue () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1641)
    UIWidgets.ListView.ScrollUpdate () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1459)
    UIWidgets.ListView.SetScrollValue (Single value) (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1304)
    UIWidgets.ListView.ValidateScrollValue () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1641)
    UIWidgets.ListView.ScrollUpdate () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1459)
    ...
     
  2. TigerHix

    TigerHix

    Joined:
    Oct 20, 2015
    Posts:
    19
    Also this is thrown when I set the data source using listViewHeight.DataSource = observableList.


    KeyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[System.String,System.Single].get_Item (System.String key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
    UIWidgets.ListViewHeight.GetIndexByHeight (Single height) (at Assets/New UI Widgets/Scripts/ListView/ListViewHeight.cs:433)
    UIWidgets.ListViewHeight.GetFirstVisibleIndex (Boolean strict) (at Assets/New UI Widgets/Scripts/ListView/ListViewHeight.cs:469)
    UIWidgets.ListView.CalculateVisibilityData () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1531)
    UIWidgets.ListView.UpdateView () (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1562)
    UIWidgets.ListView.SetNewItems (UIWidgets.ObservableList`1 newItems, Boolean updateView) (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:1732)
    UIWidgets.ListViewHeight.SetNewItems (UIWidgets.ObservableList`1 newItems, Boolean updateView) (at Assets/New UI Widgets/Scripts/ListView/ListViewHeight.cs:386)
    UIWidgets.ListView.set_DataSource (UIWidgets.ObservableList`1 value) (at Assets/New UI Widgets/Scripts/ListView/ListView.cs:77)
     
  3. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Please turn off ListView.LimitScrollValue (you can use ScrollRect.MovementType = Clamped instead).
    LimitScrollValue will be removed in the next update.

    Please uncomment line in the ListViewHeight.cs:
    SetItemsHeight(newItems);
    in the SetNewItems method.

    Or you can download fixed version 1.10.3b7.


    Can you tell for what reason are you use ListViewHeight?
    I considered it mostly useless because of the single string often is not enough (especially since ListViewCustom and widget generation available to work with custom types) and because of this ListViewHeight was not properly tested.
     
    TigerHix likes this.
  4. TigerHix

    TigerHix

    Joined:
    Oct 20, 2015
    Posts:
    19
    Thanks! Working like a charm.

    Actually, I do like to use ListViewHeight to display single strings! Like below:

    upload_2019-3-29_18-17-59.png

    This saves the trouble of setting up a custom widget.
     
    ilih likes this.
  5. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    @ilih
    is there a virtualized carousel control to show images with zoom in out support?
    if not, can you please provide one
    thanks
     
  6. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Please check Examples/ListView/TsunamiEffect/Tsunami scene.
    Zoom in/out is dependent on the distance to a cursor.
    Images should have a relative size (based on anchors - like a stretch).
     
  7. TigerHix

    TigerHix

    Joined:
    Oct 20, 2015
    Posts:
    19
    Widget generation failed with a simple class below. Do you know what's going on?

    Code (CSharp):
    1. public class Clue
    2. {
    3.     public string Description;
    4. }
    Code (csharp):
    1. ArgumentOutOfRangeException: Argument is out of range.
    2. Parameter name: index
    3. System.Collections.Generic.List`1[UIWidgets.WidgetGeneration.ClassField].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    4. UIWidgets.WidgetGeneration.ClassInfo.get_TextFieldFirst () (at Assets/New UI Widgets/Scripts/WidgetGeneration/Editor/ClassInfo.cs:142)
    5. UIWidgets.WidgetGeneration.ScriptsGenerator.ToStringList (System.String format, IFormatProvider formatProvider) (at Assets/New UI Widgets/Scripts/WidgetGeneration/Editor/ScriptsGenerator.cs:452)
    6. UIWidgets.WidgetGeneration.ScriptsGenerator.ToString (System.String format, IFormatProvider formatProvider) (at Assets/New UI Widgets/Scripts/WidgetGeneration/Editor/ScriptsGenerator.cs:400)
    7. System.String.FormatHelper (System.Text.StringBuilder result, IFormatProvider provider, System.String format, System.Object[] args) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/String.cs:1941)
    8. System.String.Format (IFormatProvider provider, System.String format, System.Object[] args) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/String.cs:1873)
    9. System.String.Format (System.String format, System.Object arg0) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/String.cs:1853)
    10. UIWidgets.WidgetGeneration.ScriptsGenerator.GetScriptCode (System.String type) (at Assets/New UI Widgets/Scripts/WidgetGeneration/Editor/ScriptsGenerator.cs:372)
    11. UIWidgets.WidgetGeneration.ScriptsGenerator.CreateScript (System.String type) (at Assets/New UI Widgets/Scripts/WidgetGeneration/Editor/ScriptsGenerator.cs:341)
    12. UIWidgets.WidgetGeneration.ScriptsGenerator.GenerateScripts () (at Assets/New UI Widgets/Scripts/WidgetGeneration/Editor/ScriptsGenerator.cs:219)
     
  8. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Sorry, typo.
    Fix:
    Replace two lines in New UI Widgets/Scripts/WidgetGeneration/Editor/ClassInfo.cs
    line 142:
    TextFields[0],

    line 162:
    Fields[0],
     
    TigerHix likes this.
  9. berry4u

    berry4u

    Joined:
    Dec 27, 2017
    Posts:
    18
    New of this asset. I'm having some troubles in starting with a simple workflow to add UI items to my project.
    First of all I tried to create a new style having the following Exception (for me is very important to be able to customize the style)
    upload_2019-4-30_18-44-0.png

    surely I'm making some mistake but as said before I haven't found a step by step procedure in the documentation and following the video tutorials I ran up against this problem.
    (I'm using 1.10.2 release and unity3d 2018.3.6f1)
     
  10. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Please make sure use you select Assets folder or any nested folder.
    Assets cannot be created outside the Assets folder, error happens if you try to do it in a search result or Favorite tab.

    Upd.: error also happens if you select a file, not folder.

    Upd. 2: error fixed, you can download v1.10.3b9.
     
    Last edited: Apr 30, 2019
  11. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    @ilih
    Hi
    You already have Drag Drop support, which is great but i encountered a different case.

    For example, there are 3 different ugui objects on canvas, and when i drag one other 2 move along with currently dragged object. just like if these 3 share same parent even though they are actually siblings.

    please advise
     
  12. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    You can try to use DragRedirect after updating to v1.10.3b10.
    Add Draggable to each object and add two DragRedirects to other objects.
     
    jGate99 likes this.
  13. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    Amazing support as usual :)
     
  14. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Released version 1.10.3
    • added GroupedTileView example
    • DragRedirect: improved support for the multiple redirects
    • GroupedList: added ItemsPerBlock, EmptyGroupItem, EmptyItem properties for the TileView support
    • EasyLayout: added Flex layout type
    • EasyLayout: added Staggered layout type
    • EasyLayout: renamed Stacking to MainAxis
    • ListView: HighlightedBackgroundColor and HighlightedColor now applied automatically after changed
    • ListView: fixed scrolling when List Type is fixed, ListScrollValue enabled and DefaultItem have Layout Group
    • ListView: fixed rare bug for the ListView with items of the variable sizes.
    • ListView: added missing fields in the Inspector window for the simple ListView
    • ListView: added TileViewStaggered renderer
    • ScrollRectPaginator: fixed displayed buttons at the start
    • Style: fixed error when style created not in the folder or outside Assets folder
    • TextMesh Pro support: improved support for the Unity 2019.1
    • Tooltip: fixed displayed tooltip after parent gameobject was disabled (thanks to Gladyon)
    • Widget Generation: fixed bug when type has only one field of the supported types
     
    hopeful and jGate99 like this.
  15. aleksandrsnegovoy

    aleksandrsnegovoy

    Joined:
    Dec 19, 2018
    Posts:
    3
    How to make such drag and drop?
    - we do drag from the source to the target
    - a drop is applied to the target
    - at the same time, the last target data of the beginning of the drag
     
  16. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    If you ask about drag-and-drop for ListView then:
    • you already should have drag-and-drop support scripts created with the widget generation
    • you need to add drag script to the source ListView and drop script for the target ListView
    • to add dropped data to the beginning you need to add the following function to the drop script:
      Code (CSharp):
      1.         protected override void AddItem(TItem item, int index)
      2.         {
      3.              ListView.DataSource.Insert(0, item);
      4.         }
      this code replaces adding data to list based on the cursor position with adding data to the beginning.
    If you need drag-and-drop for the custom widgets here is documentation about it.
     
    Last edited: May 24, 2019
  17. aleksandrsnegovoy

    aleksandrsnegovoy

    Joined:
    Dec 19, 2018
    Posts:
    3
    This is an inventory for a character, where the cells are always in their places, and only the content of the cells moves, each cell has the DragSupport and DropSupport script. (They may be located in the ListView or somewhere else it does not matter, the cells themselves do not change position)
    - I saw an example there is not shown how to do what I need
    - I have, if there is an empty cell, then it is clear to me and it already works for me.
    - How to be if both cells are occupied with content.
    - I need after a drop of content in a cell that is not empty, so that for the content of which there was automatically a drag
    or like this
     
  18. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    If you want to swap the content of the cells, then you need to modify drop script to save target data on the drop and override OnEndDrag function to set saved data to the dragged cell in the DragSupport.OnEndDrag() function.
    (То есть вам надо поменять местами данные ячеек? Тогда надо сохранить данные ячейки в скрипте IDropSupport<T> и затем записать их в перетаскиваемую ячейку в функции DragSupport.OnEndDrag().)

    Saving target cell content. (Сохранение данных ячейки.)
    IDropSupport<CellData>
    Code (CSharp):
    1.         public CellData OriginalData;
    2.  
    3.         public void Drop(CellData data, PointerEventData eventData)
    4.         {
    5.             var cell = GetComponent<Cell>();
    6.             CellData  = cell.Data;
    7.             cell.Data = data;
    8.         }
    Updated OnEndDrag() (измененная функция OnEndDrag)
    Code (CSharp):
    1.         public override void OnEndDrag(PointerEventData eventData)
    2.         {
    3.             if (!IsDragged)
    4.             {
    5.                 return;
    6.             }
    7.  
    8.             var target = FindTarget(eventData);
    9.             if (target != null)
    10.             {
    11.                 target.Drop(Data, eventData);
    12.                 Dropped(true);
    13.  
    14.                 // set target data to the original cell (запись сохраненных данных в исходную ячейку)
    15.                 GetComponent<Cell>().Data = (target as CellDropSupport).OriginalData;
    16.             }
    17.             else
    18.             {
    19.                 Dropped(false);
    20.             }
    21.  
    22.             IsDragged = false;
    23.             Cursor.SetCursor(DefaultCursorTexture, DefaultCursorHotSpot, Compatibility.GetCursorMode());
    24.         }
     
    Last edited: May 24, 2019
  19. aleksandrsnegovoy

    aleksandrsnegovoy

    Joined:
    Dec 19, 2018
    Posts:
    3
    Thanks it is worked

    var target = FindTarget(eventData);
    if (target != null)
    {
    PreDropData = target.GetPreDropData();
    target.Drop(Data, eventData);
    Dropped(true);
    PreDropData = default(T);
    }
    else
    {
    Dropped(false);
    }
     
  20. YuriPetskus

    YuriPetskus

    Joined:
    Jun 22, 2018
    Posts:
    16
    How can I fit 3 elements in height?
    The parent element is fit in the screen using the stretch-stretch anchor preset. For example, height = 500.
    Two child elements have a LayoutElement.PreferredHeight = 100.
    The height of the third element should be the parent height - the height of the first two siblings, that is 500-200 = 300.
    If the screen height is increased to 600, the height of the 3rd element should be 400.
    How do I set up a EasyLayout for this?
     
  21. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    1. Set Flexible Height for the first two elements to 0, and 1 for the third element (Flexible Height is the proportion of how remaining free space will be distributed)
    2. Set "EasyLayout.ChildrenHeight" to "Fit Container"
     
    YuriPetskus likes this.
  22. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    @ilih,
    Hi
    In many cases we dont want highlights, selected and default colors to show just a read only list. in that case when we return null

    public override UnityEngine.UI.Graphic[] GraphicsForeground
    {
    get
    {
    return null;
    }
    }

    It generates error because ListViewItem is expecting them to be not null
    GraphicsForeground.ForEach(GraphicsReset);
    GraphicsBackground.ForEach(GraphicsReset);


    I can fix this by returning empty array but we can save performance with null.

    Thanks
     
  23. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    I added null value support for the GraphicsForeground and GraphicsBackground properties
    Please update to v1.10.4b1
     
    jGate99 likes this.
  24. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    @ilih,
    I have a requirement where ill create the component for listview on runtime, assign this component as a default item to list view, and then listview redraws all items.
    Component Class itself will be typed but its look n feel will be built on runtime, so question is
    how can i ask listview to use new DefaultItem as redraws all the list items with this new one.
    Thanks
     
  25. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    secondly, is there a multi select list view demo example/scene?
     
  26. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Just set it with:
    ListView.DefaultItem = newDefaultItem;


    No, you just need to:
    • enable
      ListView.MultipleSelect
    • use
      ListView.SelectedIndices
      if you need a list of the all selected indices.
    All other things work the same as usual ListView.
     
    jGate99 likes this.
  27. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    Based on previous requirement, can we also disable background color change? right now we have to set same color values for highlight, normal, and selected background color to get 1 static look
     
  28. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    It's also was added in this update, you need to override
    GraphicsBackground
    to return null value.
     
    jGate99 likes this.
  29. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    One more thing, as you didnt just built the uGUIs best UI library but ALSO your support is unmatched.

    So do you have any plans to build a new (seperate asset with its seperate pricing) for "UI Elements" when time is right (Runtime support + visual drag drop)

    Thanks
     
  30. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Probably, the problem is when in-game UIElements will be released (it is not in the roadmap for 2019.2 and 2019.3). It can take a few years like the uGUI release.
     
    jGate99 likes this.
  31. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    I saw the visual drag drop preview few weeks ago, and they said in forum that runtime support'd be ready by 2020.1. So hopefully you will have a version ready by 2020.2 as you already know and experience what community wants (from virtualized list to other controls)
     
  32. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    @ilih,
    Hi
    Please advise how can i achieve following case:
    I have a vertical variable height list view (working)
    now each item will have a nested horizontal variable width list view, so i when i move touch/mouse up and down it moves vertical list, but when i move my mouse/touch left to right on nested horizontal list view then it moves. Is there a demo/example scene like that?
    Thanks
     
  33. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Add DragRedirect to nested ListView.ScrollRect and set parent ListView.ScrollRect as
    Redirect To
    .

    But this will work only with mouse drag, not the mouse scroll.
     
    jGate99 likes this.
  34. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    Hi,

    How can i know if a list item is selected?
    Reason is i want to show a graphic inside list item (component) based on its selection state in a multi select listview.

    Please advise
     
  35. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Probably the fastest way is to override GraphicsColoring function in the DefaultItem component. This function always called when colors should be changed like when item highlighted/selected/deselected/recycled.
    Code (CSharp):
    1.         public override void GraphicsColoring(Color foregroundColor, Color backgroundColor, float fadeDuration = 0.0f)
    2.         {
    3.             if (Owner.IsSelected(Index))
    4.             {
    5.                 // show graphic
    6.             }
    7.             else
    8.             {
    9.                 // disable graphic
    10.             }
    11.             base.GraphicsColoring(foregroundColor, backgroundColor, fadeDuration);
    12.         }
     
    jGate99 likes this.
  36. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    @ilih
    Please move signature of IsVisible to ListViewBase this way we can call it from component as Owner.IsVisible while you can still keep the implementation inside ListViewCustom
    public abstract bool IsVisible(int index)

    Thanks
     
  37. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    @ilih,
    Setting newDefaultItem doesnt seem to work,
    I also tried setting defaultItem null in editor so i can set it on runtime but got errors.

    Here is my code


    Code (CSharp):
    1. AnalysisComponent newDefaultItem = Instantiate(PrefabDefaultRenderer, ListView.Container);
    2. newDefaultItem.Sections = new AnalysisSection[schemas.Length];
    3. for (var i = 0; i < schemas.Length; i++)
    4. {
    5.     VOSchema currentSchema = schemas[i];
    6.  
    7.     AnalysisSection newSec = Instantiate(PrefabSectionRenderer, newDefaultItem.CachedRectTransform);
    8.     newSec.SetSchema(currentSchema);
    9.  
    10. }
    11. ListView.DefaultItem = newDefaultItem;
     
  38. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    I'll add it, but it will be:
    Code (CSharp):
    1.         public virtual bool IsVisible(int index)
    2.         {
    3.             return false;
    4.         }
    to have the same behavior as ListView with disabled virtualization and keep compatibility with older versions.

    Please check instantiated ListView items after replacing DefaultItem, probably it has the wrong size.
    Try this code instead:
    AnalysisComponent newDefaultItem = Instantiate(PrefabDefaultRenderer, ListView.Container, false);
     
    jGate99 likes this.
  39. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    It works but Problem is, its still reusing the old default item's cached item. So how can i ask him to destroy all the cached/pooled old items and replace with this one as new has entirely different look

    Update 2
    There should be a method which clears ComponentsPool including destroying (as user know he wont be reusing old items) pooled items to start fresh.
     
    Last edited: Jul 9, 2019
  40. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Maybe are you replacing DefaultItem for the nested ListView?
    Then you should update parent ListView after changing nested ListView.DefaultItem, like this:
    parentListView.ForEachComponent(x => x.ListView.DefaultItem = newDefaultItem);

    or this
    parentListView.DefaultItem = parentListView.DefaultItem;


    I found the problem when instantiated items not destroyed after changing DefaultItem (but they not used anymore).
    Fix:
    Add line in SetTemplate() function in ListViewComponentPool.cs
    Code (CSharp):
    1.             Components.ForEach(DeactivateComponent);
    2.             Components.ForEach(DestroyComponent);// new line
    3.             Components.Clear();
     
  41. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    Im actually replacing DefaultTemplate which is typeof AnalysisComponent with a new DefaultTemplate of same type AnalysisComponent. There are no errors as both have same type, but ListView is instantiating old defaultitems.
    I set new DefaultTemplate in Start() so something is happening.
    If you are unable to reproduce this, then ill create a sample with the issue
     
  42. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Yes, I cannot reproduce it, the sample would be great.

    Also, can you check ListView.DefaultItem value in the Inspector window during play mode? Should be displayed name of the new DefaultItem and click should highlight the prefab instance.
     
  43. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    Looks like i have finally tracked the issue,
    What happens is i'm assigning this new template on Start() which means ListView itself maybe not fully initialized at that time.
    So if i call assign my code like this
    Invoke("runWithDelay", 10);
    then it properly works,

    Reason is isListViewCustomInited is false when i set it immediatly on start();

    please advise
     
  44. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    You can init ListView from your code:
    add
    ListView.Init();
    before setting DefaultItem.
    Multiple Init() calls are safe.
     
    jGate99 likes this.
  45. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    Calling Init() solved the issue, no more manual delay calls
    i hope next update have proper fix so we dont have to call Init .
    Thanks as i can resume the work now on my side :)
     
  46. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    @ilih
    is there a multiselect dropdown?
    thanks
     
  47. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Yes, you can check example at main example scene in the Miscellaneous section.

    How to change combobox to multi-select combobox:
    • enable Combobox.ListView.MultipleSelect
    • move Combobox.Current inside newly created gameobject with layout group component (Combobox.Current will be used as a prefab to instance selected items and the layout group required to position them)
    • optional: add function ListView default item component to deselect item and button to Combobox.Current with a callback to this function.
    If you use widget generation then you can just create ComboboxMultiselect from the menu.
     
    jGate99 likes this.
  48. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    Hi @ilih,

    Problem with ComboboxMultiselect is that when we show drop down, it only let us select 1 value and then it closes itself and then we click it to open.

    It'd be really great we can have something like this example (right side)
    https://mdbootstrap.com/docs/jquery/forms/multiselect/

    Thanks
     
  49. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    715
    Replace UpdateView() function in ComboboxCustom.cs with following code:
    Code (CSharp):
    1.         /// <summary>
    2.         /// Hide ListView on item select or deselect.
    3.         /// </summary>
    4.         [SerializeField]
    5.         [Tooltip("Hide ListView on item select or deselect.")]
    6.         public bool HideAfterItemToggle = true;
    7.  
    8.         /// <summary>
    9.         /// Updates the view.
    10.         /// </summary>
    11.         protected virtual void UpdateView()
    12.         {
    13.             currentIndices = ListView.SelectedIndices;
    14.  
    15.             UpdateComponentsCount();
    16.  
    17.             components.ForEach(SetData);
    18.  
    19.             if (HideAfterItemToggle)
    20.             {
    21.                 HideList();
    22.  
    23.                 if ((EventSystem.current != null) && (!EventSystem.current.alreadySelecting))
    24.                 {
    25.                     EventSystem.current.SetSelectedGameObject(gameObject);
    26.                 }
    27.             }
    28.         }
    or update to v1.10.4b2.

    Now you can disable HideAfterItemToggle in the Inspector window, so the list will not auto closed after item selected or deselected.
     
    jGate99 likes this.
  50. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    922
    @ilih
    please add another constructer in ObservableList<T> which takes only capacity.
    Thanks