Search Unity

[RELEASED] UI Table

Discussion in 'Assets and Asset Store' started by bourriquet, Mar 14, 2019.

  1. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    An insanely easy Table Layout for Unity UI



    Asset Store Link

    Documentation
    Simple
    I uses reflection so you don't have to code anything. Just select your collection, the properties to display, and here you are.
    You can now customize the table all you want.

    Integrated
    Unity UI Table only uses and organizes Unity UI elements, so it's consistent and easy to integrate with the rest of your UI.

    Customizable

    Many Options:
    • Sortable Columns
    • Selectable Rows
    • Add/Delete Row Buttons
    • Update at Runtime or Save Performances
    • Many More...

    Feedback & feature suggestions welcome!








     
  2. minhplhl

    minhplhl

    Joined:
    Sep 11, 2017
    Posts:
    4
    upload_2019-3-22_11-20-34.png
    I try to run the example scene and this error appear when i press play button. Here is this error line.

    upload_2019-3-22_11-21-40.png
    this is the whole picture
     

    Attached Files:

  3. minhplhl

    minhplhl

    Joined:
    Sep 11, 2017
    Posts:
    4
    I can change the table data at runtime in code ??
     
  4. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Hi @minhplhl
    Yes, you can change the data at runtime. Enable the "Update Content at Runtime" option in the Performance section of the Table if you want the table to keep up-to-date.
    About your error, I see what causes it. Will fix it now. You can still go on, right? This error doesn't affect the functioning.
    Thanks for your feedback.
     
  5. linojon

    linojon

    Joined:
    Aug 25, 2014
    Posts:
    118
    hello, i've attached my component's collection List in inspector and defined the columns i want. I checked the At Runtime: Update: Cell Content. Then at runtime i populate the list, and call table.UpdateContent() but the data rows are never generated, just the header row. In the debugger, in Table.cs the targetCollection.Collection.Count is always 0. ?? I also tried calling SetDirty() before UpdateContent.
     
  6. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Hi @linojon
    You don't need to call UpdateContent (only useful when Update Cell Content option is off) or SetDirty. It normally just updates automatically if you set the option.
    What version of Unity do you use?
    Do you have any error in your console?
    Does it work when you add elements to the list in the inspector in edit mode?
    Is it possible to send me the project with the issue (or a stripped down version of course). You can email me with the mail button here: https://assetstore.unity.com/publishers/34298
     
  7. linojon

    linojon

    Joined:
    Aug 25, 2014
    Posts:
    118
    Unity 2018.3.7f1. No errors on the console.
    hi, i understand. In this case I dont need it to update automatically, its just a text panel that includes a table of data, not interactive, When the panel is enabled, i set its text and table content. I read the data from an external source at runtime Start so it doesnt make sense to add it via the inspector. In fact, the List isnt allocated (collection = new List<Myclass>()) until runtime, maybe this is the problem?
     
  8. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    @linojon I see. The table loses the connection to the list if you reallocate it after the initialization.
    Can you call the constructor in the declaration?
    Anyway I should be able to ship a fix by tomorrow.
     
  9. linojon

    linojon

    Joined:
    Aug 25, 2014
    Posts:
    118
    that did it, thanks! i new call the constructor in the declaration and use .Clear() when i want to refresh it. Works :)
     
  10. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    @linojon Great!
    I will handle this case in the next release.
    Thanks for letting me know.
     
  11. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    The new version is live and handles this situation.
    Thanks again.
     
  12. KingBradley24

    KingBradley24

    Joined:
    Sep 19, 2017
    Posts:
    10
    Hey @bourriquet ! First of all thank you so much for this asset, it's been a tremendous help!

    I have a question though, I'm basically making a player statistics page and would like for the rows to expand in height if the player has several lines of a specific statistic. Is there a way to do this? I tried the flexible heights and all that but I couldn't get it to work..

    Hope you continue working on this because it's very valuable! :)
     
  13. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Hi @KingBradley24
    Very glad the asset is helpful !
    Currently there is no way to have variable heights in the table. I will look into it and come back to you. Thanks for the suggestion.
     
    KingBradley24 likes this.
  14. KingBradley24

    KingBradley24

    Joined:
    Sep 19, 2017
    Posts:
    10
    Thank you for the quick answer @bourriquet !
    I'll keep an eye out for that update as I haven't figured out a workaround!

    Keep up your great work! :)
     
  15. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Hi @KingBradley24

    Just submitted a 1.3 update, including Expandable Height option in the columns settings.
    Attached is a screenshot showing how it works.
    (Note that the text must be set to Wrap for it to work, of course)
    There is also a new cell type: Input Cell - Expandable. A normal input field cannot be expanded, so I created the special one using the workaround mentioned here: https://forum.unity.com/threads/how...according-to-text-inside.297812/#post-3167412

    Also, I saw your review. About your point on the documentation, what part would you have liked to see explained in more details in the Manual.pdf ?
     

    Attached Files:

  16. KingBradley24

    KingBradley24

    Joined:
    Sep 19, 2017
    Posts:
    10
    Hey @bourriquet !

    Thank you so much for this update!
    Regarding the documentation, I'm a moron! :( I didn't see the manual.pdf!

    I will edit my review to disclaim the truth!

    Unfortunately, I haven't been able to use the function correctly yet, can you tell me what I'm doing wrong?
    The first cell on the table has two lines, separated by a "\n" on display ( not actually stored like that on the Collection)
    as can be seen on the second screenshot.

    However, it's not expanding correctly, can you see if there's anything wrong?
    P.S: I've tried selecting expanding height for all columns, just that column, and it didn't work.

    Thanks again, and sorry for the hassle!
     

    Attached Files:

  17. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    @KingBradley24
    Your second screenshot is just with a bigger Default Row Height, to show that the content is actually two lines, right?
    Your settings look the same as mine.
    Can you try right-clicking your Table component and choose Initialize. This will recreate the table from scratch, in case there was an issue going from 1.2 to 1.3.
    Also what version of Unity do you use?
     
  18. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Also, did you hit Play? In edit mode, the scene doesn't refresh after you check the Expandable Height box, until you change something else (just resizing the Game View will do).
     
  19. KingBradley24

    KingBradley24

    Joined:
    Sep 19, 2017
    Posts:
    10
    @bourriquet
    Correct, just a bigger Default Row Height!
    I used Initialize and it didn't work :/
    The first screenshot was from the Game view, and my Unity version is 2018.2.17f1!^
    Thank you
     
  20. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    @KingBradley24
    Can you try replacing RuntimeGUITable/Scripts/Cells/TableCell.cs with the version attached?
    Sorry for the hassle.
     

    Attached Files:

  21. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Also, if you look at the Text Cells that should but don't expand, do they have a ContentSizeFitter component? And what is the Vertical Fit set to?
     
  22. KingBradley24

    KingBradley24

    Joined:
    Sep 19, 2017
    Posts:
    10
    Hi @bourriquet !
    Sorry for the late reply, I replaced with the new file and it didn't work.
    I've attached an example of a column properties.
    Every Vertical Fit is set to "Preferred Height"
     

    Attached Files:

  23. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Hi @KingBradley24
    Actually not the columns, but the Text Cells themselves, where the Text components are.
    Here's how it looks for me.
     

    Attached Files:

  24. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Of course, if you can share the project or a stripped down version of the problem with me, that would be awesome.
     
  25. virendravishth

    virendravishth

    Joined:
    Sep 12, 2016
    Posts:
    7
    I am not able to make the table scrollable. Whenever I check the Scrollable button, it gives an error and get unchecked by itself
     
  26. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Hi @virendravishth
    Are you using Unity 2018.1 or 2018.2 ?
    There is an issue with these versions. I am releasing an update which should be live by Monday.
     
  27. virendravishth

    virendravishth

    Joined:
    Sep 12, 2016
    Posts:
    7
    I am using Unity 2018.1
     
  28. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    @virendravishth
    Yes, that's the issue then. The fix is submitted and should be live on Monday.
    If this is urgent, you can edit GameObjectUtils.cs and replace all occurences of UNITY_2018_1_OR_NEWER with UNITY_2018_3_OR_NEWER.
     
  29. KingBradley24

    KingBradley24

    Joined:
    Sep 19, 2017
    Posts:
    10
    Hey @bourriquet ! Hope you're having a wonderful weekend and keep enjoying it!

    I've selected a text cell and it does not have a content size fitter nor is the object selected for expandable element.. :/

    Not sure if you know what it could be!
     

    Attached Files:

  30. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    @KingBradley24
    Ok, that's the issue indeed. Expandable Element should not be None.
    It seems to mean that your table was not recreated properly with the new version. You did hit Initialize in the right-click menu of the Table component, right? Do you get an error in the console when you do?
     
  31. KingBradley24

    KingBradley24

    Joined:
    Sep 19, 2017
    Posts:
    10
    @bourriquet
    Yes I did, I just redid it and there is no error in console but still not working :/
    I'll rebuild the table tomorrow just in case, and will post results back here!
    Again, thanks for everything :)
     

    Attached Files:

  32. KingBradley24

    KingBradley24

    Joined:
    Sep 19, 2017
    Posts:
    10
    Hey @bourriquet !
    I created the table again and still not working..

    I don't know what else to do :/
     

    Attached Files:

  33. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    @KingBradley24
    If you look at the prefab Text Cell, is the Expandable Element also None?
    If it's also None, the plugin probably didn't update properly. You might want to delete the whole RuntimeGUITable folder and reimport the plugin from the Asset Store.
     
  34. vihist

    vihist

    Joined:
    Sep 7, 2017
    Posts:
    2
    Thank a lot!
    I find the many table tool in Unity, this is best!
     
  35. KingBradley24

    KingBradley24

    Joined:
    Sep 19, 2017
    Posts:
    10
    Hey @bourriquet !
    Sorry, haven't been able to focus on this on the last few days!

    I re-imported and updated the asset with your monday update and it is now functioning!
    Definitely an error on the import or something, but thankfully it's fixed!
    I had some issues with the scrollbars however, but removing them makes the whole table scrollable, horizontally and vertically, and is perfectly fine for the design.

    Again, thank you so much for your hard work, and keep up the great job! Definitely a valuable asset!
     
  36. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
  37. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Hi @vihist
    Very glad that it helps you. Don't hesitate to leave a review if you like it ;)
     
  38. fvr-unity

    fvr-unity

    Joined:
    Mar 10, 2017
    Posts:
    1
    Hey @bourriquet !
    there is a chance to have a c# code that show how is possible to popolate the table at RunTime ?
    Thanks
     
    digiross likes this.
  39. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Hi @fvr-unity
    Sure. Just enable the "Update content at Runtime" option in the table, then populate the referenced collection in your code (yourList.Add(element) for example). The table will update automatically.
     
  40. wenny518

    wenny518

    Joined:
    May 8, 2019
    Posts:
    2
    I used the unity asset called UI table. It is really helpful to me. While, when I used it, I have some problem and hope you can help me.
    I set the table to prefabs and I want to initialize it with new data collection in the code. Actually, I do not know how can I set the data collection for the table in the code.
    Also, when I update data in the table UI, I want to save all changed or selected data to a file. Where can I get updated data?
    I will really appreciate that you can help me. Hope I can get your help
     
  41. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Hi @wenny518
    What do you mean by "set the table to prefabs"?
    You cannot set the collection by code. It is meant to be set in the Inspector. Otherwise, you couldn't set the properties for the columns, etc. Is this a problem for you?
    When you need to get the data, just use the collection that was set in the table. If you have selected Update Content at Runtime, the data will be the same.
     
    Last edited: Jun 7, 2019
  42. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    Is this supposed to work in 2017? The example appears correct in the editor most of the time but sometimes when I run it, the table rotates 90 degrees and the elements stretch vertically to infinity. (edit: I think maybe the missing fonts I fixed in the example fixed it).

    Right now, it always seems to grow from the center, I can't find a combination of anchor settings to constrain the top edge of the table to a specific Y value and have the table grown down from there. Is this possible? Looks like I may have to change the code itself to do it?

    It would also be nice if there was a TextMeshPro version of this asset. Fonts look so much better with TMP than the standard Unity font rendering.
     
    Last edited: Jun 9, 2019
  43. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    @Obsurveyor

    I tested with 5.6 and 2019. I will check 2017. I haven't witnessed what you are describing. Could you share some screenshots?

    Set the Table's pivot's Y to 1 instead of the default 0.5 to have it anchored from the top.

    Good idea. Will be done quickly.
     
  44. wenny518

    wenny518

    Joined:
    May 8, 2019
    Posts:
    2
    Thanks a lot. I still have a problem to click Add button, it will occur object reference not set to an instance of an object and index was out of range in InputCell.cs. Could you help me?
     
  45. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    @wenny518
    I will have a look at that.
    The TextMeshPro cell is almost ready (it was more complicated than expected).
     
  46. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    Hi @wenny518
    Sorry for the delay.
    The update supporting TextMeshPro is now live (1.4).
    I found the bug with Input Cells. I will submit another update.
    In the meantime, I can give you the fix.
    Replace the UpdateContent function in Input Cell with this one:
    Code (CSharp):
    1. public override void UpdateContent()
    2. {
    3.     if (property == null || property.IsEmpty)
    4.         return;
    5.     object o = property.GetValue(obj);
    6.     if (o != null)
    7.         inputField.text = o.ToString();
    8.     if (IsDecimalType(property.Type))
    9.         inputField.contentType = InputField.ContentType.DecimalNumber;
    10.     if (IsIntegerType(property.Type))
    11.         inputField.contentType = InputField.ContentType.IntegerNumber;
    12.     if (IsStringType(property.Type))
    13.         inputField.contentType = InputField.ContentType.Standard;
    14. }
    Thank you for your feedback!
     
  47. KAYUMIY

    KAYUMIY

    Joined:
    Nov 12, 2015
    Posts:
    115
    Data coming from XML file should be displayed in the Scene during run time. is It possible to show XML data in the scene by using this asset?
    I cannot make it...
     
    Last edited: Jun 27, 2019
  48. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    KAYUMIY likes this.
  49. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    So something like that should work.
    Then you link myList in the Table. And call Table.UpdateContent() when the list is ready.

    Code (CSharp):
    1. public class XML2ListConverter : MonoBehaviour
    2.  
    3.     public List<MyClass> myList;
    4.  
    5.     void Start()
    6.     {
    7.         XmlSerializer serializer = new XmlSerializer(typeof(List<MyClass>));
    8.         using (FileStream stream = File.OpenRead("XMLFile"))
    9.         {
    10.             List<MyClass> dezerializedList = (List<MyClass>)serializer.Deserialize(stream);
    11.         }
    12.     }
    13.  
    14. }
     
    KAYUMIY likes this.
  50. KAYUMIY

    KAYUMIY

    Joined:
    Nov 12, 2015
    Posts:
    115

    I tried to do what you said. but there is problem File.OpenRead("XMLFile") , xml file is path to my xml file is it right?
    I wrote address to my xml file location. but it does not work.

    Can you explain in detail about this method File.OpenRead("XMLFile") ?