Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

New UI Widgets

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

  1. GTMeghana

    GTMeghana

    Joined:
    Jan 5, 2023
    Posts:
    19

    Thanks for you reply regarding position my i have position autocombobox at z = -20 and inputfield at z = 0
    in a prefab below first image shows the input input of second prefab is behind the list but when we see it straight it looks like list is behind the input field.
    and regarding setting events to receive to pointer i have done that and some times it works but mostly its not working.


    Thanks you
    upload_2024-2-23_12-8-15.png upload_2024-2-23_12-9-33.png
     
  2. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    The inspector window shows the local position, not the global position.
    Please check the z position of the parents' game objects. Or you can open AutoCombobox in Play mode and then change the z position to different values in the Inspector and check results in the Scene view.

    What New UI Widgets version are you using?
    Some versions had problems with the Toggle button, try to update to the latest version.
     
  3. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,999
    Hi @ilih
    For LinearGroupedTileView, which Datasource should i use in?
    CanSelect
     
  4. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    You should use
    GroupedData
    property to add/remove items.
    Code (CSharp):
    1. ListView.GroupedData.Add(item);
    2. ListView.GroupedData.AddRange(items);
    3. ListView.GroupedData.Remove(item);
    4. ListView.GroupedData.Clear();
     
    jGate99 likes this.
  5. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,999
    Hi @ilih
    When i pass List to LinearGroupedTileView, then LinearTileView autoamtically adds items in between (empty items).
    Now problem is, in my case when i get the index in SetData that index is not based on my original list data index.

    So is there any method which i can call which return my index for my list?
    Please advise
     
  6. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    You can get item by index from DatsSource and then find index of this item in the original list (items should be unique).
    Code (CSharp):
    1. var item = (Owner as GroupedListView).DataSource[Index];
    2. var original_index = OriginialList.IndexOf(item);
     
    jGate99 likes this.
  7. jGate99

    jGate99

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

    I understand above case, however i'm using it in different way

    Instead of passing items, i pass lets say manager classes
    So first 5 index will have 1 same manager class as item (and that manager class internally will have items for those 5 indexes as dictionary)

    So is there a possibility i can get the original item index from DataSource index?
    Thanks
     
  8. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    No.

    You can use a wrapper to combine the original index and manager and use it instead of the current item type.
    Code (CSharp):
    1. public struct ManagerWrapper
    2. {
    3.    public int Index;
    4.    public Manager Manager;
    5. }
     
    jGate99 likes this.
  9. sp3ck

    sp3ck

    Joined:
    Jul 1, 2020
    Posts:
    13
    hi. im trying to use the timeline view but im getting this error everytime i try to drag a timeline item. how can i solve this?
     

    Attached Files:

  10. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    Sorry for the problem.

    Fix:
    Please replace a line in the
    OnDrag()
    method in the Scripts / Drag-and-Drop / DragSupport.cs
    old line:
    Code (CSharp):
    1.             if (Utilities.IsNull(CurrentAutoScrollTarget))
    new line (invert condition check):
    Code (CSharp):
    1.             if (!Utilities.IsNull(CurrentAutoScrollTarget))
     
  11. sp3ck

    sp3ck

    Joined:
    Jul 1, 2020
    Posts:
    13
    yeah i already did actually. figured you forgot the `!`. no worries. new question! im trying to get the drag and drop (Drop Rect Transform) to work with the timeline, but it doesnt seem to be working well together. all when i manually instantiate the default items outside of timeline and drag it, i get the console error. what is the best way to acheive this?
     

    Attached Files:

  12. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    If I understand correctly: you manually created instances of the game object with the DataView and DataDragSupport component.

    DataView is used to display actual data and DataDragSupport works with data displayed by DataView. (This is done to display only visible items: game objects instances are created only for visible items, and those instances are reused when some items become hidden and others visible after scroll).

    Data is null by default. So after creating an instance you need to call the
    SetData()
    method of the DataView component.
    Like this:
    Code (CSharp):
    1. var instance = Instantiate(Timeline.DefaultItem);
    2.  
    3. var dummy_track = new Track<TimelineData, TimeSpan>();
    4. instance.SetData(dummy_track, new TimelineData() {
    5.    StartPoint = new TimeSpan(),
    6.    EndPoint = new TimeSpan(0, 1, 0), // 1 minute
    7.    Name = "Outside Item",
    8. });
     
    Last edited: Mar 4, 2024
  13. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    v1.17.6 released

    Changelog:
    • added SplitterMaxSize component to limit the maximum size of the Splitter targets (set value to 0 to disable)
    • added SliderScroll component for the Slider widget with ScrollMode option to change the value on the mouse scroll
    • CircularSlider: added ScrollMode option to change the value on the mouse scroll
    • CenteredSlider: added ScrollMode option to change the value on the mouse scroll
    • Drag: fixed the AutoScroll error
    • ObservableList: added UseStableSort option, enabled by default
    • ObservableList: added optional “bool stable” parameter to the Sort() methods
    • SnapGrid: fixed problem with the Canvas scale factor
    • small optimizations and code improvements
     
  14. sp3ck

    sp3ck

    Joined:
    Jul 1, 2020
    Posts:
    13
    got it thanks! i found out 3 issues pertaining to the timeline as i continue using it.

    1. when i initialize the start time as 0,0,0 , the tilmeline items dont show unless i scroll the timeline to the right and go back (i have to scroll alot, like past the 5 seconds marker). however, when i set the start time to 1, they show properly.
    **refer to the screenshots**

    2. when resizing, even when the cursor changes, i am unable to resize unless i hold my mouse down for at least 1 second before moving it. or else, it doesnt get resized.

    any ideas?
     

    Attached Files:

  15. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    What is the third issue?

    Can you show how you add items?

    I tested with this code and it works fine.
    Code (CSharp):
    1. var t = new TimelineData()
    2. {
    3.    Name = "Start At 0",
    4.    StartPoint = new TimeSpan(0, 0, 0),
    5.    EndPoint = new TimeSpan(0, 0, 4),
    6. };
    7. timeline.Tracks[0].Data.Add(t);
    Upd.: If you are using
    timeline.Tracks.BeginUpdate();
    make sure you have also a
    timeline.Tracks.EndUpdate();
    .

    The Resizable behavior was changed in v1.17.3 to allow resizing when the cursor is outside of the target in ActiveRegion distance (previously only when it was inside).
    But Timeline also uses ScrollRect and ScrollRect gets a drag event when the cursor is outside of the item instead of Resizable.

    As a workaround, you can make the following changes to the Resizable.cs and then disable the
    IncludeOuterRegion
    option for the Resizable component on the DataDefaultItem object. This way resize (and cursor change) only be available when the cursor is inside of the Resizable component.
    • add a new field
      Code (CSharp):
      1.         /// <summary>
      2.         /// Use outer region.
      3.         /// </summary>
      4.         [SerializeField]
      5.         [Tooltip("Allow resizing when the cursor in ActiveRegion distance outside of RectTransform.")]
      6.         public bool IncludeOuterRegion = true;
    • change
      GetTargetRect()
      method
      Code (CSharp):
      1.         protected Rect GetTargetRect(float activeRegion)
      2.         {
      3.             var rect = Target.rect;
      4.  
      5.             if (IncludeOuterRegion)
      6.             {
      7.                 rect.x -= activeRegion;
      8.                 rect.y -= activeRegion;
      9.                 rect.width += activeRegion * 2;
      10.                 rect.height += activeRegion * 2;
      11.             }
      12.  
      13.             return rect;
      14.         }
    I'll try to find a proper solution for this case.
     
    Last edited: Mar 6, 2024
  16. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    Should be fixed in v1.17.7b2.
     
  17. sp3ck

    sp3ck

    Joined:
    Jul 1, 2020
    Posts:
    13
    Thanks. It works smoother now.

    This is a seperate issue. Does the Resizeable script by any chance disables some sort of event systems listener or something? Because after implementing the timeline in my actualy project, everytime the tracks load the track item (the one with the resizable) script on, my menu buttons become unclickable. but when i disable the resizeable script, they work fine again. Any idea?

    P/S: This was happening even before the latest fix, so, i believe it is not caused by any changes to the fix.
     
  18. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    Maybe some game object with transparent image placed over buttons so it blocks clicks.
    If you set large Resizable.ActiveRegion then can be a reason why clicks are blocked, but this has only been possible since the last update and the cursor should be changed, so it is easy to notice.

    Upd.: Please check the nested objects for the object with the Resizable component. Probably one of them is much larger parent and block clicks.

    You can check what object blocks click with EventSystem:
    • enter play mode
    • select EventSystem in the Hierarchy window
    • expand the bottom block in the Inspector window
    • check the "Current Raycast" information when cursors over buttons and they are unclickable
    upload_2024-3-9_22-0-59.png
     
    Last edited: Mar 9, 2024
  19. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,999
    Hi @ilih
    Please review the video of linear grid layout, if i scroll down its all good but when i start to scroll up then video issue happens. please advise
    https://we.tl/t-q2xMrjiHkS
     
  20. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    Please check the width of all templates (DefaultItem), it should be the same for all items.
    Probably templates for the empty header or empty item have different widths and because of this layout became incorrect.
     
    Last edited: Mar 11, 2024
    jGate99 likes this.
  21. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,999
    I set the width from inside SetData and tiles have different widths (all the tiles have same) and group has different width (all the groups have same width but could have different height)
     
  22. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    The widths in the editor mode should be the same.
    Items per row are calculated using the lowest widths.

    For example, if the empty header width is 80, but the item width and empty item width are 100, and the TileView width is 400.
    The result will be 5 items per row (400 / 80 = 5), but empty headers are disabled and you will see items and empty items, but they will be 4 per row (400 / 100 = 4).
    All is fine at the start, but this difference between calculated items per row and visible items per row will cause problems like in the video.
     
    jGate99 likes this.
  23. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,999
    So if i understand correctly, i need to make sure I set the right values for hiddem items too. thats it,
    Setting sizes in SetData should work as long as every defaultitem gets the right size
     
  24. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    Yes.
     
    jGate99 likes this.
  25. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,999
    you are genius Sir for implementing it like this, problem resolved
     
  26. cookiedrugs

    cookiedrugs

    Joined:
    Jul 21, 2022
    Posts:
    6
    I'm currently trying to create a table. I know that with the generator I can create a table from a data class. But in one case I need a "generic" table with a variable number of columns. My idea would be to create two classes that have a similar structure to the generated classes ListViewXXX and ListViewComponentXXX (I don't need drag/drop/sort for now).

    The class ListViewGenericData would be empty because I don't need sorting and the class ListViewComponentGenericData would have a IList<TextAdapter>, which can also be changed at runtime, and some methods like the generated one.

    Would that be a valid approach, or have I thought too far and I'm missing something?
     
  27. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    Yes.
    You can check a demo with such a table for
    List<int>
    in the Examples / Table / TableList folder.
     
    cookiedrugs likes this.
  28. sainozakobukikoku

    sainozakobukikoku

    Joined:
    Apr 21, 2020
    Posts:
    4
    Hello. I'm trying to use New UI Widgets.
    However, I have a problem, so I would like to ask you a question.
    When I applied Generate Widgets to a simple class, only the TileView at the bottom left was displayed correctly, and the characters in the other ListView and TreeView were not displayed properly as shown in the image.
    Code (CSharp):
    1. namespace UIWidgets.Examples
    2. {
    3.     using System;
    4.     using UnityEngine;
    5.  
    6.     [Serializable]
    7.     public class test
    8.     {
    9.         [SerializeField]
    10.         public string Name;
    11.  
    12.     }
    13. }
    This can be seen by enlarging the frame of the Name object, but it appears to be abnormal behavior.
    This phenomenon occurs when the Default Font Asset is set to NotoSansJP-Medium. (Add SDF)
    https://drive.google.com/drive/folders/1x_fG7DCWYM6wKL-Dw_m3JhXe5Gu5TS5i?usp=sharing

    Why does this phenomenon occur?

    Unity 2022.3.19f1
    New UI Widgets 1.17.6f2
     

    Attached Files:

  29. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    This happens because different fonts with the same font size have very different text sizes.
    And if the text is larger than can fit in RectTransform then the text will not be displayed (if Overflow is set to Truncate).
    (I do not know if is this a problem with TMPro or fonts but default Text does not have such problems).

    Solutions:
    • increase DefaultItem height
    • reduce the font size so the text will fit RectTransform (if you use Theme you can change all font sizes there)
      upload_2024-3-13_19-52-20.png
    • increase TMPro Overflow settings to Overflow instead of Truncate
      upload_2024-3-13_19-43-9.png
     
  30. sainozakobukikoku

    sainozakobukikoku

    Joined:
    Apr 21, 2020
    Posts:
    4
    Thank you for your quick reply.
    It was also helpful to know multiple ways to deal with the problem.
     
  31. sainozakobukikoku

    sainozakobukikoku

    Joined:
    Apr 21, 2020
    Posts:
    4
    I would like to ask you something again.
    The text was created using the generator earlier, but as a result of being generated according to the Default Font Asset in Project Settings, it is no longer visible.
    However, the Default UI Theme is set in Theme Target. Isn't this strange? If so, shouldn't it be set to LiberationSar, which is the Theme's Default Font?
    Also, will the Default Theme not be applied?

    (I would like to see how the theme I created looks in multiple UIs of Scenes created with the Demo or generator, but I couldn't figure out how to do it easily.)
     
  32. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    All themes except the Default UI Theme can be edited: colors, font sizes, etc can be changed or deleted, same for variations.
    Themes are attached by matched values: the color of the image or text should match with one of the color options of the theme.
    Those matches can be guaranteed only for the Default UI Theme because it cannot be edited and it has all the required colors and variations.
    This is why the default theme is not applied.

    But I overlooked the problem with the default font, I'll try to find a fix for this.

    Solution for now:
    1. create a new theme (if you do not have it already)
    2. make it default (button at the bottom left in the theme editor window)
    3. use the "UI / UI Themes / Remove All ThemeTargets" command on the canvas at your scene
    4. use the "UI / UI Themes / Attach Theme and Create Option" command on the canvas at your scene
     
  33. sp3ck

    sp3ck

    Joined:
    Jul 1, 2020
    Posts:
    13
    hi. i figured out the issue with why my other menu buttons that aren't working. Its because of the Resizable Root. when i disable it, everything works fine again. I don't think your plugin should be messing with the root canvas system because there will be use cases where your asset is not the only one being used.
    also, when the Resizable components are destroyed, the Resizable Root component is still there. It shouldn't. I have spent a lot of time figuring this out, so, I would appreciate it if you fix it urgently.
     

    Attached Files:

  34. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    Please update to v1.17.7b6 and disable
    IncludeOuterRegion
    option for the all Resizable components.
    In this case, Resizable Root will not be created: it is required for resize when the pointer is outside of the Resizable object, and if IncludeOuterRegion is disabled it is not needed.
     
  35. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    Please check v1.17.7b6
    I made a few changes:
    • added the "Attach to the Scene" button to the Theme editor, it will add/replace all themes in the active scene with the current one
    • scene created by Widgets Generator now uses a separate copy of the base theme and this theme will use the default font
     
  36. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,999
    Hi @ilih
    In my listview whenever i try to set LayoutElement somevalues in SetData, those get resets to minWidth minHeight 0
    Any idea?
     
  37. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    Maybe you have TableHeader that has a reference to this ListView?
    It changes LayoutElement values to match with header values.
     
  38. sp3ck

    sp3ck

    Joined:
    Jul 1, 2020
    Posts:
    13
    why would you ask me to disable IncludeOuterRegion?? the cursor acts all weird if i disable it. that is not a fix. im still waiting for a proper fix.
     
  39. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    Because you do not want to use ResizableRoot.
    To change the cursor and resize an object the Resizable component should receive PointerEnter, PointerExit, OnBeginDrag, OnDrag, and OnEndDrag events.
    But objects receive those events only if the pointer is over them. It is how Unity uGUI works and it cannot be changed.
    ResizableRoot is required to receive those events and redirect them to the correct resizable object when the pointer is outside of resizable objects.

    Another solution: add ResizableRoot to the some parent game object of the Resizable object but which does not include or cover buttons.

    For the proper fix, I need more information: I still have not received an answer on what object blocks clicks on buttons.
    Also, I'll need a screenshot of the game view with buttons and the resizable object; and how buttons and the resizable object are placed in the hierarchy.
    But better will be the scene to reproduce this problem.

    Upd.:
    No, it is not of because ResizableRoot. It was added only in v1.17.7b2.
    And by your words:
     
    Last edited: Mar 16, 2024
  40. sainozakobukikoku

    sainozakobukikoku

    Joined:
    Apr 21, 2020
    Posts:
    4
    Thank you for your prompt fix.
    I appreciate that I can easily change the theme.
     
  41. sp3ck

    sp3ck

    Joined:
    Jul 1, 2020
    Posts:
    13
    the resizable issue was prevalent even before the the fix. i didnt know at that time what was causing which issue. there were multiple issues if you recall properly. (cursor icon, resizeable mouse sensitivity, etc.). i didnt write the code nor do i have the time to weed through them all.

    as for the `object blocks clicks on buttons' issue. i did not say specifically that it was blocking. it appeared as such. my other buttons react when i hover and all and only becomes unclickable when the resizeable root component is present in the main canvas in which your UI elements and my other buttons share the same parent wayyyy up the hierarchy.

    i created a simple fix for now, disabling the resizeable root when curson isnt over any resizeable elements. i will try to add the resizeable root manually and see what happens.
     
  42. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    There are not a lot of reasons why a button can be unclickable:
    • They are blocked by some graphics componenta: a transparent image can be over the button and it will block click.
      In this screenshot image is not fully transparent to be visible.
      upload_2024-3-20_19-30-56.png
    • The Button component is disabled (not the game object)
    • Interactable property is disabled for the Button or parent CanvasGroup
    • EventSystem is disabled, but then Resizable also will not work.
    The first one is the most probable reason, others are possible if you subscribe to some event and disable/enable in code.

    For now, I do not have enough information: know only that there are unclickable buttons if the Resizable component is used on scene.
    Despite all my tries, I was not able to reproduce this problem.
     
  43. cookiedrugs

    cookiedrugs

    Joined:
    Jul 21, 2022
    Posts:
    6
    There's one thing I don't understand right now. How does the presetting of the values in ThemeTarget work if, for example, I add a button via "'UI --> New UI Widgets --> Default --> Button". The ThemeTarget component is added automatically. But only some values are set. Can this logic be customized?
     
  44. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    Automatically added ThemeTarget will have None options in the following cases:
    • for the Selectable component: default values of normal, highlighted, pressed, selected, and disabled colors; color multiplier,
    • null sprites,
    • theme does not have such value (color, sprite, font, font size, etc).
    This is done because the Selectable color tint is a multiplier, not a replacement for the text or image color.
    (I'll upload a video about the Selectable and how to work with it next week).

    Solutions:
    • change the
      ShouldAttachValue()
      method in the UI Themes / Scripts / Wrappers / Selectable Selectable{type}Color.cs
      replace lines like:
      return widget.colors.normalColor != ColorBlock.defaultColorBlock.normalColor;

      with
      return true;

      (I'll add a setting to always set the Selectable colors instead of code change in v1.17.8)
    • change the Selectable colors in the prefabs:
      - create copies of Assets / UI Themes / PrefabsThemes.asset and prefabs
      - replace prefab references with created copies
      - change the Selectable colors to not default
      - add those colors to the theme.
      The ThemeTarget values will be set since the Selectable colors are not default.
     
    cookiedrugs likes this.
  45. cookiedrugs

    cookiedrugs

    Joined:
    Jul 21, 2022
    Posts:
    6
    The colors of selectable are not my problem. I don't understand the behavior of the FontSize property. When I add a "Button", the fontSize of the child "Text" is set to "base", but when I add a "Text", the value remains at "none". Why isn't it consistent? And where does “base” come from?


    And I have another problem. My generic table works almost perfectly. Unfortunately the items will not be resized correctly at the beginning.
    upload_2024-3-25_9-1-17.png

    After I change the size of a column it works.
    upload_2024-3-25_9-1-47.png

    What could be the reason? My code is something like that:
    Code (CSharp):
    1. class SomeExplicitListClass {
    2.     private void Start() {
    3.         var table = GetComponent<GenericTableView>();
    4.         table.AddColumn("first column");  // my method, see below
    5.         table.AddColumn("second column");
    6.         for (int i = 0; i < 10; ++i) {
    7.             table.DataSource.Add(...);
    8.         }
    9.         // I tried...
    10.         // table.Resize()
    11.         // table.Header.Resize()
    12.     }
    13. }
    14.  
    15. class GenericTableView : ListViewCustom<GenericTableViewComponent, object> {
    16.  
    17.     public void AddColumn(string name) {
    18.         foreach (var component in GetComponentsEnumerator(PoolEnumeratorMode.All)) {
    19.             AddCellToRow(component);
    20.         }
    21.         ComponentsColoring();
    22.         AddColumnToHeader(name);
    23.     }
    24.  
    25.     private void AddColumnToHeader(string name) {
    26.         var column = Compatibility.Instantiate(columnTemplate);
    27.         column.TextAdapter.text = name;
    28.         column.gameObject.SetActive(true);
    29.         Header.AddCell(column.gameObject);
    30.         Header.Resize();
    31.     }
    32.  
    33.     private void AddCellToRow(GenericTableViewComponent row) {
    34.         var cell = Compatibility.Instantiate(cellTemplate);
    35.         cell.transform.SetParent(row.transform, false);
    36.         cell.gameObject.SetActive(true);
    37.         row.AddCellComponent(cell);
    38.         row.UpdateView();
    39.     }
    40.  
    41. }

    Edit:

    When I add this code to the class SomeExplicitListClass, it works. But this cannot be the solution:
    Code (CSharp):
    1. class SomeExplicitListClass {
    2.     ...
    3.     private bool firstUpdate = true;
    4.     private void Update() {
    5.         if (firstUpdate) {
    6.             inputTableView.Header.Resize();
    7.             firstUpdate = false;
    8.         }
    9.     }
    10. }
     
    Last edited: Mar 25, 2024
  46. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    The default theme has predefined values, if you open the "Font Sizes" tab in a theme editor, you will see all options' names with their values for each variation (Blue, Red, Legacy).
    "Base" is an option with font size = 14, and if the Text component has font size = 14, then in ThemeTarget it will be set to Base.
    If the Text component has a font size is 11 and there is no option with such value in the initial variation it will be set to None.
    This is applied to the widgets created from the menu or command "Attach Theme".

    If the Text component was manually added after ThemeTarget was added you need to click "Find" for the initial or active variation and it will update the selected options based on values.
    Or you can use "Attach Theme and Create Options" or "Find or Create": both of them will add a new option if there is no any with such value.

    upload_2024-3-25_12-59-32.png

    upload_2024-3-25_13-8-7.png


    Code (CSharp):
    1.     private void AddCellToRow(GenericTableViewComponent row) {
    2.         var cell = Compatibility.Instantiate(cellTemplate);
    3.         cell.transform.SetParent(row.transform, false);
    4.         cell.gameObject.SetActive(true);
    5.         row.AddCellComponent(cell);
    6.         row.UpdateView();
    7.     }
    I see 2 cells in the header and 4 cells in each data row in the screenshot.
    The most probable reason is that you instantiate the template in the
    GenericTableView.AddCellToRow()
    method and then in the
    row.AddCellComponent(cell);
    method it is instantiated a second time. So each row has twice as many data cells as the header.
    If I am right then you need to remove one of the unnecessary instantiate calls.
     
    cookiedrugs likes this.
  47. cookiedrugs

    cookiedrugs

    Joined:
    Jul 21, 2022
    Posts:
    6
    Actually you can see 8 cells in each row. Its because the CompactConstraint of EasyLayout in the scroll view content is "Flexible". So 4 rowes are displayed in one row. I could set it to "MaxColumnCount = 1", but this is not the problem. The widths of the cells are not set, only with a later call "Header.Resize()".
     
  48. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    Can you show how the table looks with MaxColumnCount = 1?
    I cannot reproduce this problem, probably it is related to the scripts execution orders and/or layout calculation.

    As an alternative to the SomeExplicitListClass, you can add this line to the end of the Start() method:
    Updater.RunOnceNextFrame(Header.Resize);
     
  49. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,456
    v1.17.7 released

    Changelog:
    • COMPATIBILITY-BREAKING CHANGES: now
      BeginUpdate()
      method of
      IObservableList<T>
      ,
      ObservableList<T>
      , and
      GroupedList<T>
      returns
      ListUpdater
      instead of
      void
    • Calendar: now the OutOfRangeDate option is properly used instead of the OtherMonth
    • Calendar: now the date is selectable
    • Dialog: added AutoFocus option - set focus to the last Selectable object in the Dialog
    • DragSupport: fixed bug with
      OnDestroy()
    • IObservableList<T>
      ,
      ObservableList<T>
      ,
      GroupedList<T>
      : now
      BeginUpdate()
      method returns disposable struct to automatically call
      EndUpdate()
      at the end of the block (
      using var _ = DataSource.BeginUpdate();
      );
    • Notifications: added FadeIn and FadeOut animations (requires CanvasGroup component)
    • ListView: fixed navigation for the ListViewEllipse type
    • Picker: added AutoFocus option - set focus to the last Selectable object in the Picker
    • Popup: added AutoFocus option - set focus to the last Selectable object in the Popup
    • Resizable: added the IncludeOuterRegion option to enable/disable resize outside of the target (disabling it restores behavior before v1.17.3)
    • Resizable: improved compatibility with other draggable components like ScrollRect
    • Resizable: ResizableRoot can be manually added to the parent object instead of the canvas
    • Resizable: ResizableRoot is no longer required if IncludeOuterRegion is disabled
    • TableHeader: fixed bug with destroyed cells
    • small optimizations and code improvements
    • UI Themes: “Remove All ThemeTargets” renamed to “Detach Theme”
    • UI Themes: “Remove ThemeTargets with Default Theme” renamed to “Detach Default Theme”
    • UI Themes: added “Attach to the Scene” button to the Theme editor, it will add/replace all themes in the active scene with the current one
    • Settings: auto-attach theme now is disabled by default
    • Widgets Generator: the created scene now uses a separate copy of the base theme
    • Widgets Generator: fixed duplication of foregrounds list in DefaultItem if all of them are null
     
    Last edited: Mar 25, 2024
  50. sgmdev

    sgmdev

    Joined:
    Jul 26, 2023
    Posts:
    32
    Hello! I'm looking to use the TileView to create a list of vertical images. I am looking for something very similar to the Tiktok search results where you have 2 rectangular images per row and you scroll down to see more items.
    How would I go about doing this?

    I see that the listview has a bunch of options (ListViewString, ListViewIcon, ListViewInt etc) and I'm not quite sure how to do this.