Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

New UI Widgets

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

  1. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Notice, how previousy i made your switch class partial, so i could add my own code (left side) without extending the switch class
    Now im no longer able to do that after importing latest beta version
    as unity is not recoginzing both as same class.
    Did you add asmdf something like that?

    upload_2023-3-29_3-4-5.png
     
  2. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    Yes, but you can disable asmdef from Edit / Project Settings... / New UI Widgets.
    After that, you can change the Switch class to partial and it will work.
    upload_2023-3-29_1-12-51.png
     
    jGate99 likes this.
  3. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Thanks, I tried this but it still doesnt recoginze it as the same same class but rather 2 seperate classes :(
    upload_2023-3-29_5-48-24.png

    I'm on Unity 2023.1 Beta
     
  4. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    What exact error messages did you get?
     
  5. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    I enabled again, and then disabled again, and now it properly recongized 2 files as one.


    Now coming back to list view problem,
    I checked on Enable were never overriden.

    I think problem is that scene in which list view is, is disabled (whole canvas) and i set data and enabled a the same time, maybe thats causing the issue?
     
  6. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    Maybe, please try to call
    ListView.UpdateView()
    or
    Updater.RunOnceNextFrame(() => ListView.UpdateView());
    after enabling canvas.
     
    jGate99 likes this.
  7. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Unfortunately it didnt solve this issue either

    Is there any possibility if you could exted print debug info in a way so you could see what is causing the issue?
     
  8. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    Please also try:
    ListView.Resize()
    or
    Updater.RunOnceNextFrame(() => ListView.Resize());


    Add following lines at end of
    GetDebugInfo()
    method before
    return
    in ListViewCustom.cs:
    Code (CSharp):
    1.             sb.AppendLine("#############");
    2.             sb.AppendLine("**Runtime Info**");
    3.             sb.AppendLine("NeedResize: " + NeedResize);
    4.             sb.AppendLine("NeedUpdateView: " + NeedUpdateView);
     
    jGate99 likes this.
  9. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Wow, Amazing @ilih, this solved the problem Updater.RunOnceNextFrame(() => ListView.Resize());

    However, let me comment this line "Updater.RunOnceNextFrame(() => ListView.Resize());" and then send you print debug log anyway so you can see the issue in detail
     
  10. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796

    Code (CSharp):
    1. Direction: Vertical
    2. Type: ListViewWithVariableSize
    3. Virtualization: True
    4. DataSource.Count: 104
    5. Container Size: (387.00, 9778.21)
    6. Container Scale: (1.00, 1.00, 1.00)
    7. DefaultItem Size: (337.00, 12.00)
    8. DefaultItem Scale: (1.00, 1.00, 1.00)
    9. Viewport Size: (387.00, 800.00)
    10. Looped: False
    11. Centered: False
    12. Precalculate Sizes: True
    13. DisplayedIndices (count: 12): 0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11
    14. Components Indices (count: 12):
    15. 0 PrefabDefaultItemText(Clone): 0
    16. 1 PrefabDefaultItemText(Clone): 1
    17. 2 PrefabDefaultItemSeparator(Clone): 2
    18. 3 PrefabDefaultItemControls(Clone): 3
    19. 4 PrefabDefaultItemControls(Clone): 4
    20. 5 PrefabDefaultItemControls(Clone): 5
    21. 6 PrefabDefaultItemControls(Clone): 6
    22. 7 PrefabDefaultItemControls(Clone): 7
    23. 8 PrefabDefaultItemControls(Clone): 8
    24. 9 PrefabDefaultItemControls(Clone): 9
    25. 10 PrefabDefaultItemControls(Clone): 10
    26. 11 PrefabDefaultItemControls(Clone): 11
    27. Templates (count: 5):
    28. 0 PrefabDefaultItemText; Instances.Count: 2; Requested.Count: 0; Cache.Count: 0
    29. 1 PrefabDefaultItemGroupHeader; Instances.Count: 0; Requested.Count: 0; Cache.Count: 0
    30. 2 PrefabDefaultItemSeparator; Instances.Count: 1; Requested.Count: 0; Cache.Count: 0
    31. 3 PrefabDefaultItemControls; Instances.Count: 9; Requested.Count: 0; Cache.Count: 0
    32. 4 PrefabDefaultItemButton; Instances.Count: 0; Requested.Count: 0; Cache.Count: 0
    33. StopScrollAtItemCenter: False
    34. ScrollCenterState: None
    35. ScrollPosition: 0
    36. ScrollVectorPosition: (0.00, 0.00)
    37.  
    38. #############
    39. **Renderer Info**
    40. IsTileView: False
    41. Max Visible Items: 12
    42. Visibility
    43. Visibility.FirstVisible: 0
    44. Visibility.LastVisible: 12
    45. Visibility.Items: 12
    46. First Visible Index: 0
    47. Last Visible Index: 16
    48. List Size: 9778.21
    49. Items Per Block: 1
    50. Top Filler: 0
    51. Bottom Filler: 9200
    52. Items
    53.     0. size: (387.00, 43.60); position: 0; block: 0
    54.     1. size: (387.00, 40.61); position: 43.6; block: 1
    55.     2. size: (387.00, 44.00); position: 84.21; block: 2
    56.     3. size: (387.00, 50.00); position: 128.21; block: 3
    57.     4. size: (387.00, 50.00); position: 178.21; block: 4
    58.     5. size: (387.00, 50.00); position: 228.21; block: 5
    59.     6. size: (387.00, 50.00); position: 278.21; block: 6
    60.     7. size: (387.00, 50.00); position: 328.21; block: 7
    61.     8. size: (387.00, 50.00); position: 378.21; block: 8
    62.     9. size: (387.00, 50.00); position: 428.21; block: 9
    63.     10. size: (387.00, 50.00); position: 478.21; block: 10
    64.     11. size: (387.00, 50.00); position: 528.21; block: 11
    65.     12. size: (1.00, 100.00); position: 578.21; block: 12
    66.     13. size: (1.00, 100.00); position: 678.21; block: 13
    67.     14. size: (1.00, 100.00); position: 778.21; block: 14
    68.     15. size: (1.00, 100.00); position: 878.21; block: 15
    69.     16. size: (1.00, 100.00); position: 978.21; block: 16
    70.     17. size: (1.00, 100.00); position: 1078.21; block: 17
    71.     18. size: (1.00, 100.00); position: 1178.21; block: 18
    72.     19. size: (1.00, 100.00); position: 1278.21; block: 19
    73.     20. size: (1.00, 100.00); position: 1378.21; block: 20
    74.     21. size: (1.00, 100.00); position: 1478.21; block: 21
    75.     22. size: (1.00, 100.00); position: 1578.21; block: 22
    76.     23. size: (1.00, 100.00); position: 1678.21; block: 23
    77.     24. size: (1.00, 100.00); position: 1778.21; block: 24
    78.     25. size: (1.00, 100.00); position: 1878.21; block: 25
    79.     26. size: (1.00, 100.00); position: 1978.21; block: 26
    80.     27. size: (1.00, 100.00); position: 2078.21; block: 27
    81.     28. size: (1.00, 100.00); position: 2178.21; block: 28
    82.     29. size: (1.00, 100.00); position: 2278.21; block: 29
    83.     30. size: (1.00, 100.00); position: 2378.21; block: 30
    84.     31. size: (1.00, 100.00); position: 2478.21; block: 31
    85.     32. size: (1.00, 100.00); position: 2578.21; block: 32
    86.     33. size: (1.00, 100.00); position: 2678.21; block: 33
    87.     34. size: (1.00, 100.00); position: 2778.21; block: 34
    88.     35. size: (1.00, 100.00); position: 2878.21; block: 35
    89.     36. size: (1.00, 100.00); position: 2978.21; block: 36
    90.     37. size: (1.00, 100.00); position: 3078.21; block: 37
    91.     38. size: (1.00, 100.00); position: 3178.21; block: 38
    92.     39. size: (1.00, 100.00); position: 3278.21; block: 39
    93.     40. size: (1.00, 100.00); position: 3378.21; block: 40
    94.     41. size: (1.00, 100.00); position: 3478.21; block: 41
    95.     42. size: (1.00, 100.00); position: 3578.21; block: 42
    96.     43. size: (1.00, 100.00); position: 3678.21; block: 43
    97.     44. size: (1.00, 100.00); position: 3778.21; block: 44
    98.     45. size: (1.00, 100.00); position: 3878.21; block: 45
    99.     46. size: (1.00, 100.00); position: 3978.21; block: 46
    100.     47. size: (1.00, 100.00); position: 4078.21; block: 47
    101.     48. size: (1.00, 100.00); position: 4178.21; block: 48
    102.     49. size: (1.00, 100.00); position: 4278.21; block: 49
    103.     50. size: (1.00, 100.00); position: 4378.21; block: 50
    104.     51. size: (1.00, 100.00); position: 4478.21; block: 51
    105.     52. size: (1.00, 100.00); position: 4578.21; block: 52
    106.     53. size: (1.00, 100.00); position: 4678.21; block: 53
    107.     54. size: (1.00, 100.00); position: 4778.21; block: 54
    108.     55. size: (1.00, 100.00); position: 4878.21; block: 55
    109.     56. size: (1.00, 100.00); position: 4978.21; block: 56
    110.     57. size: (1.00, 100.00); position: 5078.21; block: 57
    111.     58. size: (1.00, 100.00); position: 5178.21; block: 58
    112.     59. size: (1.00, 100.00); position: 5278.21; block: 59
    113.     60. size: (1.00, 100.00); position: 5378.21; block: 60
    114.     61. size: (1.00, 100.00); position: 5478.21; block: 61
    115.     62. size: (1.00, 100.00); position: 5578.21; block: 62
    116.     63. size: (1.00, 100.00); position: 5678.21; block: 63
    117.     64. size: (1.00, 100.00); position: 5778.21; block: 64
    118.     65. size: (1.00, 100.00); position: 5878.21; block: 65
    119.     66. size: (1.00, 100.00); position: 5978.21; block: 66
    120.     67. size: (1.00, 100.00); position: 6078.21; block: 67
    121.     68. size: (1.00, 100.00); position: 6178.21; block: 68
    122.     69. size: (1.00, 100.00); position: 6278.21; block: 69
    123.     70. size: (1.00, 100.00); position: 6378.21; block: 70
    124.     71. size: (1.00, 100.00); position: 6478.21; block: 71
    125.     72. size: (1.00, 100.00); position: 6578.21; block: 72
    126.     73. size: (1.00, 100.00); position: 6678.21; block: 73
    127.     74. size: (1.00, 100.00); position: 6778.21; block: 74
    128.     75. size: (1.00, 100.00); position: 6878.21; block: 75
    129.     76. size: (1.00, 100.00); position: 6978.21; block: 76
    130.     77. size: (1.00, 100.00); position: 7078.21; block: 77
    131.     78. size: (1.00, 100.00); position: 7178.21; block: 78
    132.     79. size: (1.00, 100.00); position: 7278.21; block: 79
    133.     80. size: (1.00, 100.00); position: 7378.21; block: 80
    134.     81. size: (1.00, 100.00); position: 7478.21; block: 81
    135.     82. size: (1.00, 100.00); position: 7578.21; block: 82
    136.     83. size: (1.00, 100.00); position: 7678.21; block: 83
    137.     84. size: (1.00, 100.00); position: 7778.21; block: 84
    138.     85. size: (1.00, 100.00); position: 7878.21; block: 85
    139.     86. size: (1.00, 100.00); position: 7978.21; block: 86
    140.     87. size: (1.00, 100.00); position: 8078.21; block: 87
    141.     88. size: (1.00, 100.00); position: 8178.21; block: 88
    142.     89. size: (1.00, 100.00); position: 8278.21; block: 89
    143.     90. size: (1.00, 100.00); position: 8378.21; block: 90
    144.     91. size: (1.00, 100.00); position: 8478.21; block: 91
    145.     92. size: (1.00, 100.00); position: 8578.21; block: 92
    146.     93. size: (1.00, 100.00); position: 8678.21; block: 93
    147.     94. size: (1.00, 100.00); position: 8778.21; block: 94
    148.     95. size: (1.00, 100.00); position: 8878.21; block: 95
    149.     96. size: (1.00, 100.00); position: 8978.21; block: 96
    150.     97. size: (1.00, 100.00); position: 9078.21; block: 97
    151.     98. size: (1.00, 100.00); position: 9178.21; block: 98
    152.     99. size: (1.00, 100.00); position: 9278.21; block: 99
    153.     100. size: (1.00, 100.00); position: 9378.21; block: 100
    154.     101. size: (1.00, 100.00); position: 9478.21; block: 101
    155.     102. size: (1.00, 100.00); position: 9578.21; block: 102
    156.     103. size: (1.00, 100.00); position: 9678.21; block: 103
    157.  
    158. #############
    159. **Layout Info**
    160. Layout: EasyLayout
    161. RectTransform.size: (387.00, 9778.21)
    162. localScale: (1.00, 1.00, 1.00)
    163. Main Axis: Horizontal
    164. Type: Compact
    165.     Group Position: UpperLeft
    166.     Row Align: Left
    167.     Inner Align: Top
    168.     Compact Constraint: Flexible
    169.     Compact Constraint Count: 1
    170. PaddingInner: Padding(left: 0, right: 0, top: 0, bottom: 9200)
    171. Spacing: (0.00, 0.00)
    172. Margin Symmetric: True
    173. Margin: (0.00, 0.00)
    174. TopToBottom: True
    175. RightToLeft: False
    176. Skip Inactive: True
    177. Reset Rotation: False
    178. Children Width: DoNothing
    179. Children Height: SetPreferred
    180. Children: PrefabDefaultItemText(Clone): (387.00, 43.60)
    181. PrefabDefaultItemText(Clone): (387.00, 40.61)
    182. PrefabDefaultItemSeparator(Clone): (387.00, 44.00)
    183. PrefabDefaultItemControls(Clone): (387.00, 50.00)
    184. PrefabDefaultItemControls(Clone): (387.00, 50.00)
    185. PrefabDefaultItemControls(Clone): (387.00, 50.00)
    186. PrefabDefaultItemControls(Clone): (387.00, 50.00)
    187. PrefabDefaultItemControls(Clone): (387.00, 50.00)
    188. PrefabDefaultItemControls(Clone): (387.00, 50.00)
    189. PrefabDefaultItemControls(Clone): (387.00, 50.00)
    190. PrefabDefaultItemControls(Clone): (387.00, 50.00)
    191. PrefabDefaultItemControls(Clone): (387.00, 50.00)
    192. #############
    193. **Runtime Info**
    194. NeedResize: False
    195. NeedUpdateView: False
    196.  
    197. UnityEngine.Debug:Log (object,UnityEngine.Object)
    198. UIWidgets.ListViewBase:PrintDebugInfo ()
     
  11. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Hi @ilih
    I have multiple Vertical List Views with shared IListViewTemplateSelector.
    Now I want to use same shared IListViewTemplateSelector for a LinearGroupedTileView

    So when the same TItemView is shown in LinearGroupedTileView i want to set a fixed Size (so its tile) and when its on vertical list then i want its width to be auto fit and height to be variable.

    So which function of VerticalList and LinearGroupedTileView I need to override for that? SetData is fine or is there a better/optimized option?

    Thanks
     
  12. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Question 2

    HeaderEmpty items are inactive, which is great for optimization/performance, but ItemEmpty is not inactive,
    any reason behind it? Can you also make it inactive? Thanks

    upload_2023-4-6_15-33-57.png
     
  13. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    SetData()
    should be fine.
    But you need to disable Precalculate Item Sizes option if the list type is one with variable size.

    It's a limitation because of how EasyLayout works: the item should be stretched at full width or should empty item to fill the empty space.
    It does not affect performance because the used components do not have the
    Update()
    method.
     
  14. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    @ilih
    Thanks,
    I want use same ListView for both LinearTileView when needed and then vertical by changing List Type, on runtime

    As LinearTileView overrride resize and updateItems , so is following approach fine?



    Code (CSharp):
    1.         public override void UpdateItems()
    2.         {
    3.             base.UpdateItems();
    4.  
    5.             if (isTileView)
    6.             {
    7.                 groupedData.ItemsPerBlock = ListRenderer.GetItemsPerBlock();
    8.  
    9.             }
    10.             else
    11.             {
    12.                 //what for list
    13.             }
    14.         }
    15.  
    16.         public override void Resize()
    17.         {
    18.             base.Resize();
    19.  
    20.             if (isTileView)
    21.             {
    22.                 groupedData.ItemsPerBlock = ListRenderer.GetItemsPerBlock();
    23.  
    24.             }
    25.             else
    26.             {
    27.                 //what for list
    28.             }
    29.         }
    Secondly what to do else part of this?

    groupedData.Input = realDataSource;
    groupedData.Output = DataSource;

    Thanks
     
  15. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    First, you do not need
    if (isTileView)
    checks in
    UpdateItems()
    and
    Resize()
    methods.

    It depends on what ListView you want.
    • If you need ListView with header items then no other changes are needed.
    • If you do not need header items then add the
      IsTileView
      property to toggle
      DataSource
      , something like this:
      Code (CSharp):
      1.         public bool IsTileView
      2.         {
      3.             get
      4.             {
      5.                 return isTileView;
      6.             }
      7.             set
      8.             {
      9.                 Init();
      10.  
      11.                 isTileView = value;
      12.                 DataSource = value ? GroupedData.Output : RealDataSource;
      13.             }
      14.         }
     
    jGate99 likes this.
  16. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Hi @ilih
    I decided to keep LinearTileView renderer seperate (to keep life easier)
    My question is if LinearTileView header item can have variable size (vertical layout with content size fitter) while tileview items will b fixed height width,
    Will this work fine?
     
  17. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    Yes, it will work fine.
     
    jGate99 likes this.
  18. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    and what should is set for children height? Set preferred?
     
  19. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    Yes, and add LayoutElement with the specified preferred size for the simple items (not headers).
     
    jGate99 likes this.
  20. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Hi @ilih
    How do i check how many components are in cache and being used for a shared IListViewTemplateSelector that are being used by multiple list controls

    What I think is not happening is that if i have 3 list view control, and i show renderers on 3rd, then clear it, go back to second clear it and then go back to first and then show 2nd list view so im assuming 2nd list view will show cached renderers that i created when i was showing 2 and 3 list
    Is this assumption right?

    Update 3:
    So instead of 3 listview having their own cached renderers in memory, those 3 listviews should give cached renderers back to IListViewTemplateSelector so same IListViewTemplateSelector can power x number of listviews with minimal requirement for creating new components
     
    Last edited: Apr 8, 2023
  21. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    You can run this code in ListView method:
    Code (CSharp):
    1.             var cached = 0;
    2.             var active = 0;
    3.             foreach (var t in Templates)
    4.             {
    5.                 cached += t.Cache.Count;
    6.                 active += t.Instances.Count;
    7.             }
    Not exactly.
    IListViewTemplateSelector is only used to specify which templates (DefaultItems) should be used.
    To have the common cache, you need to use the same template collection for the ListView.
    Code (CSharp):
    1.         List<ListViewIcons.Template> SharedTemplates = new List<ListViewIcons.Template>();
    2.  
    3.         public void SetShared()
    4.         {
    5.             foreach (var l in Lists)
    6.             {
    7.                 l.SetSharedTemplates(SharedTemplates);
    8.             }
    9.         }
    Please check Examples / ListView / SharedTemplates.
     
    jGate99 likes this.
  22. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    So if i want to use IListViewTemplateSelector along with shared templates then ill provide base class to ?
    List<BaseTemplateClass> SharedTemplates = new List<BaseTemplateClass>();
     
  23. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    Just
    List<YourListView.Template>
    .
    Template class already defined in
    ListViewCustom<TItemView, TItem>
    and you can use this definition
    List<ListViewCustom<YourComponentType, YourDataType>.Template>
    instead but the only difference is that it will be longer.
     
    jGate99 likes this.
  24. jGate99

    jGate99

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

    Im using LinearTileView and if you look at Category 2 how it moves to 2nd row and back to first row
    https://we.tl/t-lgVfKshef1

    Please advise how to solve this issue.
    Thanks


    Here is print log
    Code (CSharp):
    1. Direction: Vertical
    2. Type: TileViewWithVariableSize
    3. Virtualization: True
    4. DataSource.Count: 103
    5. Container Size: (507.45, 22328.82)
    6. Container Scale: (1.00, 1.00, 1.00)
    7. DefaultItem Size: (500.45, 12.00)
    8. DefaultItem Scale: (1.00, 1.00, 1.00)
    9. Viewport Size: (507.45, 800.00)
    10. Looped: False
    11. Centered: False
    12. Precalculate Sizes: True
    13. DisplayedIndices (count: 18): 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21
    14. Components Indices (count: 18):
    15. 0 PrefabDefaultItemControls(Clone): 4
    16. 1 PrefabDefaultItemControls(Clone): 5
    17. 2 PrefabDefaultItemControls(Clone): 6
    18. 3 PrefabDefaultItemControls(Clone): 7
    19. 4 PrefabDefaultItemControls(Clone): 8
    20. 5 PrefabDefaultItemControls(Clone): 9
    21. 6 PrefabDefaultItemControls(Clone): 10
    22. 7 PrefabDefaultItemControls(Clone): 11
    23. 8 PrefabDefaultItemControls(Clone): 12
    24. 9 PrefabDefaultItemControls(Clone): 13
    25. 10 PrefabDefaultItemControls(Clone): 14
    26. 11 PrefabDefaultItemControls(Clone): 15
    27. 12 PrefabDefaultItemControls(Clone): 16
    28. 13 PrefabDefaultItemControls(Clone): 17
    29. 14 PrefabDefaultItemControls(Clone): 18
    30. 15 PrefabDefaultItemControls(Clone): 19
    31. 16 PrefabDefaultItemControls(Clone): 20
    32. 17 PrefabDefaultItemControls(Clone): 21
    33. Templates (count: 5):
    34. 0 PrefabDefaultItemText; Instances.Count: 3; Requested.Count: 0; Cache.Count: 2
    35. 1 PrefabDefaultItemGroupHeader; Instances.Count: 0; Requested.Count: 0; Cache.Count: 0
    36. 2 PrefabDefaultItemSeparator; Instances.Count: 2; Requested.Count: 0; Cache.Count: 1
    37. 3 PrefabDefaultItemControls; Instances.Count: 29; Requested.Count: 0; Cache.Count: 0
    38. 4 PrefabDefaultItemButton; Instances.Count: 1; Requested.Count: 0; Cache.Count: 0
    39. StopScrollAtItemCenter: False
    40. ScrollCenterState: None
    41. ScrollPosition: 407.1856
    42. ScrollVectorPosition: (0.00, 407.19)
    43.  
    44. #############
    45. **Renderer Info**
    46. Rows: 18
    47. Columns: 1
    48. BlockSizes: 50; 50; 50; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234; 243.7234
    49.  
    50. #############
    51. **Layout Info**
    52. Layout: EasyLayout
    53. RectTransform.size: (507.45, 22328.82)
    54. localScale: (1.00, 1.00, 1.00)
    55. Main Axis: Horizontal
    56. Type: Compact
    57.     Group Position: UpperLeft
    58.     Row Align: Left
    59.     Inner Align: Top
    60.     Compact Constraint: Flexible
    61.     Compact Constraint Count: 1
    62. PaddingInner: Padding(left: 0, right: 0, top: 393.7234, bottom: 19741.6)
    63. Spacing: (0.00, 0.00)
    64. Margin Symmetric: True
    65. Margin: (10.00, 0.00)
    66. TopToBottom: True
    67. RightToLeft: False
    68. Skip Inactive: True
    69. Reset Rotation: False
    70. Children Width: DoNothing
    71. Children Height: DoNothing
    72. Children: PrefabDefaultItemControls(Clone): (243.72, 243.72)
    73. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    74. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    75. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    76. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    77. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    78. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    79. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    80. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    81. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    82. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    83. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    84. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    85. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    86. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    87. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    88. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    89. PrefabDefaultItemControls(Clone): (243.72, 243.72)
    90. #############
    91. **Runtime Info**
    92. NeedResize: False
    93. NeedUpdateView: False
    94.  
     
  25. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    Problem with this:
    You have items in half-width and a header in full-width, this is why
    Columns: 1
    .
    It should be GroupedTileView with empty header items and width resize done in SetData() (by default width should be half of full)
    Code (CSharp):
    1.         public override void SetData(Photo item)
    2.         {
    3.             // ...
    4.  
    5.             // disable empty group
    6.             gameObject.SetActive(!(Item.IsEmpty && Item.IsGroup));
    7.  
    8.             // stretch group item
    9.             var width = Item.IsGroup
    10.                 ? (Layout.transform as RectTransform).rect.width - Layout.MarginFullHorizontal
    11.                 : 80f;
    12.             RectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
     
    jGate99 likes this.
  26. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    I tried following code and still same issue, reason im doing in List class and not its renderer/component is because im reusing the component both in tile as well as vertical listview


    Code (CSharp):
    1. protected override void SetData(ViewItem component, SharedItem item)
    2.         {
    3.            
    4.            
    5.            
    6.             if (CanSetData)
    7.             {
    8.                
    9.                 base.SetData(component, item);
    10.  
    11.                 var itemType = item.type;
    12.  
    13.                 var isTile = itemType.HasFlagsUnSafe(SharedItemType.Tile);
    14.                 var isEmpty = itemType.HasFlagsUnSafe(SharedItemType.Empty);
    15.                
    16.                 if (isEmpty && isTile == false)
    17.                 {
    18.                     component.SetActive(false);
    19.  
    20.                 }
    21.                 component.LayoutElement.enabled = false;
    22.  
    23.                 component.cachedRectTransform.SetAnchorsToTopLeft();
    24.  
    25.                 var totalWidth = cachedRectTransform.rect.width - layout.MarginFullHorizontal;;
    26.  
    27.                 if (isTile == false && isEmpty == false)
    28.                 {
    29.  
    30.            
    31.  
    32.                     component.cachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, totalWidth);
    33.  
    34.                 }
    35.              
    36.            
    37.                 if (isTile)
    38.                 {
    39.              
    40.                     var itemWidth = (totalWidth / 2) - 25;
    41.                     component.cachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, itemWidth);
    42.  
    43.                
    44.                 }
    45.                
    46.                
    47.  
    48.             }
    49.            
    50.  
    51.            
    52.         }

    When you say "It should be GroupedTileView " what i should actually do?
    Ideally i prefer LinearGroupedTileView approaach
     
  27. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    Probably game object PrefabDefaultItemGroupHeader should have the full width of the container by default, instead of the half-width. This is why Columns = 1 and item "Category 1" is positioned incorrectly.
    To fix this PrefabDefaultItemGroupHeader should be half-width by default and then the width should be changed to full in
    SetData()
    .

    It's can be LinearGroupedTileView.
    By GroupedTileView I mean you should have some wrapper to insert empty items after the header and rows with odd item counts. You can use
    LinearGroupedList<T>
    or
    GroupedList<T>
    for this purpose.
    For example:
    items list: header 1, item 1, item 2, item 3, header 2, item 4, item5
    will be displayed like this:
    Code (CSharp):
    1. header 1 | item 1
    2. item 2   | item 3
    3. header 2 | item 4
    4. item5    |
    should be changed to the list: header 1, empty header, item 1, item 2, item 3, empty item, header 2, empty header, item 4, item5
    and will be displayed like this:
    Code (CSharp):
    1. header 1 | empty header (disabled)
    2. item 1   |  item 2
    3. item 3   | empty item
    4. header 2 | empty header (disabled)
    5. item 4   | item5
     
    Last edited: Apr 9, 2023
    jGate99 likes this.
  28. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Thanks for being patient with me,

    So i used it Linear previously like this
    public ObservableList<AvatarInventorySharedTileViewDataItem> realDataSource = new ObservableList<AvatarInventorySharedTileViewDataItem>(100);
    public LinearGroupedList<AvatarInventorySharedTileViewDataItem> groupedData = new LinearGroupedList<AvatarInventorySharedTileViewDataItem>(x => x.type == SharedTileViewType.Heading);

    And it worked well,
    and It is also creating those fake items, however I dont remember I had to create those fake items, these were added automatically

    So Can i use the same approach for my case too?

    Code (CSharp):
    1.             TemplateSelector = new Selector(headerTemplate, itemTemplate, headerEmptyTemplate, itemEmptyTemplate);
    2.  
    3.             base.Init();
    4.  
    5.             groupedData.EmptyHeaderItem = new AvatarInventorySharedTileViewDataItem() { type = SharedTileViewType.Heading, isEmpty = true };
    6.             groupedData.EmptyItem = new AvatarInventorySharedTileViewDataItem() { isEmpty = true };
    7.             groupedData.ItemsPerBlock = ListRenderer.GetItemsPerBlock();
    8.  
    9.             groupedData.Input = realDataSource;
    10.             groupedData.Output = DataSource;
    11.            
    12.             CanSelect = IsItem;
     
  29. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Resolved it by properly overriding
    new LinearGroupedList<SharedItem>(SharedItem.IsHeaderInTileViewDelegate);
    My mistake was not treating header items seperatly

    now only issue is that virtualized items are like 3x the size of 8 visible items.
     
  30. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    Please check LayoutElement and LayoutGroup components on DefaultItem.
    Probably have Min or Preferred Height specified or large spacing value.
     
    jGate99 likes this.
  31. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Sorry i meant its not the "visual size" but number of templates that are created more than they should be
    Please check the image
    upload_2023-4-10_12-49-48.png
     
  32. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    For TileView with variable size instances created based on template or item with the smallest size.
    Roughly instances count = ceil(height / smallest item height) + 1
     
    jGate99 likes this.
  33. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Hi @ilih
    So LinearGroupedList shows fixed size tile items
    what if i want to set those items size on runtime? for example on mobile view it will have 2 columns layout so item resizes to take half the width, but on tablet i show 4-5 items in row (total width/4)

    Could please guide me where do i set those sizes (before what)? or a sample where this behaviour works?
     
  34. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    You can try to determine device type (mobile or tablet) by screen size and dpi and then set DefaultItem width based on device type.
    You should do it in
    Init()
    method before
    base.Init()
    call.

    Code (CSharp):
    1. public override void Init()
    2. {
    3.     if (isGroupedListViewInited)
    4.     {
    5.         return;
    6.     }
    7.  
    8.     isGroupedListViewInited = true;
    9.  
    10.     // calculate screen size
    11.     var screen_size_inches = Mathf.Sqrt((Screen.width ^ 2 + Screen.height ^ 2)  / (float)(Screen.dpi > 0 ? Screen.dpi : 96));
    12.  
    13.  
    14.     // mobile if screen less 7" else tablet
    15.     var is_mobile = screen_size_inches < 7;
    16.  
    17.     // calculate item width (or use fixed width)
    18.     var width = Container.rect.width;
    19.     var item_width = is_mobile ? width / 2f : width / 4f;
    20.  
    21.     // set DefaultItem sizes
    22.     ItemTemplate.RectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, item_width);
    23.     ItemEmptyTemplate.RectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, item_width);
    24.  
    25.     base.Init();
    26.  
     
    jGate99 likes this.
  35. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    As I'm using IListViewTemplateSelector along with shared templates, so I cant set size on Init() because that size would have changed for some other list which'd be using these templates,
    So I think I need a method override which when takes the template from IListViewTemplateSelector and SharedTemplates to use in this lineartileview, then i set the size first and handover to lineartileview?


    Update 2:
    Just to be clear, I use shared templates/IListViewTemplateSelector in multiple list with different sizes, this is why i need to set sizes before item takes.

    Thanks again
     
    Last edited: Apr 12, 2023
  36. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    I'll think about what can be done with it.
     
    jGate99 likes this.
  37. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Thanks, appreciate that
     
  38. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    To give you more context,

    I precalculate sizes of both headers (height and full width) and tile view item , save them in "SharedItem" class, and also set those sizes in emptyHeader and emptyItem class and on SetData method i set their sizes

    protected override void SetData(SharedViewItem component, SharedItem item)


    And it seems to be working except that their is a jerk/stutter when header item appears or disappears
    https://we.tl/t-lm659Jyx6I
     
    Last edited: Apr 13, 2023
  39. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Hi @ilih
    My ListViewItem has 2 child containers, and i want to change parent of a child element from one container to other, but when i call SetParent i get this error

    Setting the parent of a transform which resides in a Prefab Asset is disabled to prevent data corruption

    Please advise
     
  40. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    Probably the only way to solve this is to unpack the prefab.
     
    jGate99 likes this.
  41. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    but Im calling this method inside SetData of ListView
    ) (at Assets/New UI Widgets/Scripts/ListView/ListViewCustom.cs:1928)
     
    Last edited: Apr 15, 2023
  42. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    You are working with prefab in
    SetData()
    method, not game object at the scene, and Unity does not allow to change
    So you should add this prefab to the scene or use
    Instantiate(prefab)
    and work with an instance.

    Try to click on the game object that you are using in
    SetData()
    , this will highlight the prefab, not the object at the scene.
    upload_2023-4-15_18-19-47.png

    Code (CSharp):
    1.     public class TestPrefab : MonoBehaviour
    2.     {
    3.         [SerializeField]
    4.         public RectTransform PrefabObject; // reference to prefab in Project files
    5.  
    6.         // You cannot do this for the prefabs (game objects that are not at the scene)
    7.         public void ChangePrefabParent() => PrefabObject.SetParent(transform);
    8.  
    9.         [SerializeField]
    10.         public RectTransform SceneObject;// reference to object at scene
    11.  
    12.         // But it will work for the objects at scene
    13.         public void ChangeSceneParent() => SceneObject.SetParent(transform);
    14.     }
     
  43. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    I added a method to change template size in v1.16.0b15, but for now, it will not work correctly with shared templates.
    Usage in ListView class:
    Code (CSharp):
    1. public override void Init()
    2. {
    3.     if (isGroupedListViewInited)
    4.     {
    5.         return;
    6.     }
    7.  
    8.     isGroupedListViewInited = true;
    9.  
    10.     GetTemplate(HeaderTemplate).DefaultSize = new Vector2(400, 50);
    11.     GetTemplate(HeaderEmptyTemplate).DefaultSize = new Vector2(100, 50);
    12.     GetTemplate(ItemTemplate).DefaultSize = new Vector2(100, 100);
    13.     GetTemplate(ItemEmptyTemplate).DefaultSize = new Vector2(100, 100);
     
    jGate99 likes this.
  44. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Thanks for the update, but as im forced to use shared list view with shared templating so ill wait until full support is available.

    I believe we should be able to set the size by override a method when any listview gets the template (either new or from pooled).

    Thanks again for patiently listening to feedback and making new ui wedgets great
     
  45. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    Yes, support for the shared templates will be added a little later.
     
    jGate99 likes this.
  46. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Awesome
     
  47. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Hi @ilih
    How can I add slides on runtime in DoubleCarousel?
    So idea is that on runtime ill transform.SetParent(myCustomSlide) where myCustomSlide will b fully stretched image container and similar call for Texts container (rectrransforms)
    Thanks
     
  48. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    You can use
    AddSlide()
    method:
    DoubleCarousel.AddSlide(DoubleCarousel.Count, text_rect_transform, background_rect_transform);

    SetParent()
    call in unnecessary, it will be done in
    AddSlide()
    .
     
    jGate99 likes this.
  49. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,278
    Shared templates list support was added in v1.16.0b16
    Usage:

    Code (CSharp):
    1.  
    2. public override void Init()
    3. {
    4.     if (isGroupedListViewInited)
    5.     {
    6.         return;
    7.     }
    8.  
    9.     isGroupedListViewInited = true;
    10.  
    11.     OverridenTemplateSizes[new InstanceID(HeaderTemplate)] = new Vector2(400, 50);
    12.     OverridenTemplateSizes[new InstanceID(HeaderEmptyTemplate)] = new Vector2(100, 50);
    13.     OverridenTemplateSizes[new InstanceID(ItemTemplate)] = new Vector2(100, 100);
    14.     OverridenTemplateSizes[new InstanceID(ItemEmptyTemplate)] = new Vector2(100, 100);
     
    jGate99 likes this.
  50. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,796
    Thanks @ilih,
    This size is set on initialization, what if i have to change it on runtime, multiple times
    For example, first time when i show grouped list it will have sized based on 3 columns, next time i show it based on 2 columns, how could i do that?
    Thanks