Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Table Pro: When Your Data isn't a Game

Discussion in 'Assets and Asset Store' started by slumtrimpet, Aug 15, 2015.

  1. WalterBoyd

    WalterBoyd

    Joined:
    Sep 25, 2015
    Posts:
    13
    Figure out it's somehow related to an Animator component I have on the canvas. Removing it restores functionality, but screws up other stuff of course. I'll await your thoughts.
     
  2. WalterBoyd

    WalterBoyd

    Joined:
    Sep 25, 2015
    Posts:
    13
    I had an animation that was not being called or used, that had a reference to the main canvas. Removing that seems to have fixed the issue. Seems like a bug, but easy enough to work around for me.

    So, on to my next problem: Automatic resizing isn't working very well. The table is consistently wider than it needs to be. Any tips?
     
  3. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Hi
    Glad you figured out the animator issue. We'll keep an eye on that on our end to see if that's something we can catch for.

    Regarding the auto-sizing... are you seeing that in one of the sample scenes in particular or can you provide an example where you're seeing this behavior? We've tried hard to make that as solid as possible, and it is as far as we know, but I don't doubt you might have found a glitch on a specific case. We'd be happy to check it out if you want to PM a sample project link or something over.

    Thanks
     
  4. HectorSilva

    HectorSilva

    Joined:
    Jun 20, 2015
    Posts:
    20
    Hi Slumtrimpet.

    I have a couple of questions.

    1) I'm trying to make a table with icons. I have reviewed the KitchenSink example and have relied upon to make my own table. All good, except that within the space for the image I get a blank box instead of the icon. I think the problem is that I have not been able to properly indicate the image to each element of the dictionary. What I have done, it is to associate each image with its sprite using the Select button in Inspector, but does not work for me. As I see it, in the KitchenSink example you do not associate the images with the sprites in this way, but I can not identify how you do it. How do I relate each image with its sprite? (Maybe this question is elementary, it's just I'm learning Unity).

    2) On the other hand, is there any way to indicate a percentage fixed length for each column and a "best fit" for the font size?

    Thanks in advance for your support.
     
  5. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    1)

    The sprites are associated via a Dictionary<string, Sprite> spriteDict you pass to the table initialize function like:
    this.table.initialize(selectionCallback, spriteDict);

    You can see how that dictionary is populated in the KitchenSink.cs example code.

    You then pass values to image columns that are the string keys of the sprites you want to display from your sprite dictionary.

    2)

    No, not at this time. You can define a min and max width for a column but that's it. Also, no best-fit font size is supported either. We found that didn't look very good having a table with multiple font-sizes during our testing.

    Thanks!
     
  6. HectorSilva

    HectorSilva

    Joined:
    Jun 20, 2015
    Posts:
    20
    Thanks for your excellent response time, Slumtrimpet. Basically my doubt is how you indicate that "personal.png" file, for example, is the image associated with sprite1 (kmix.png with sprite2, and so on).
     
  7. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Here's the exact flow:

    1 - We've got public attrs on our script that we associate with sprites in the editor:

    Code (csharp):
    1. public Sprite sprite1;
    2. public Sprite sprite2;
    3. public Sprite sprite3;
    4. public Sprite sprite4;
    5. public Sprite sprite5;
    2 - We define a dictionary to associate those sprites with arbitrary names:

    Code (csharp):
    1. this.spriteDict = new Dictionary<string, Sprite>();
    2. this.spriteDict.Add("1", this.sprite1);
    3. this.spriteDict.Add("2", this.sprite2);
    4. this.spriteDict.Add("3", this.sprite3);
    5. this.spriteDict.Add("4", this.sprite4);
    6. this.spriteDict.Add("5", this.sprite5);
    3 - We pass said dictionary to our table initializer:

    Code (csharp):
    1. this.table.initialize(this.selectionCallback, this.spriteDict);
    4 - We randomly choose a sprite to display (you'd of course manually set this to the string 'key' of your sprite in the dictionary in a real implementation):

    Code (csharp):
    1. List<string> keyList = new List<string>(this.spriteDict.Keys);
    2. d.elements.Add(keyList[rand.Next(keyList.Count)]);
     
  8. HectorSilva

    HectorSilva

    Joined:
    Jun 20, 2015
    Posts:
    20
    I have finally been able to incorporate icons in the table,Slumtrimpet. The problem was my inexperience with Unity, I was dragging pngs to a wrong place. Thank you very much for your support and patience.

    Best regards!
     
  9. VadimDobrogursky

    VadimDobrogursky

    Joined:
    Jul 2, 2015
    Posts:
    6
    I have faced a problem that I can't customize skin with prefabs or something. And that is very very bad. How to change table looks?
     
  10. MorrK

    MorrK

    Joined:
    Nov 11, 2012
    Posts:
    3
    Hi is there a way to make the first column sticky or to add something like the header to the left of the table?
     
  11. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Nope, we don't support that currently.
     
  12. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Sorry for the late reply on this. You can change pretty much all major color/font/sizing/etc setting on the table via code or the custom editor. I'm not sure how you attempted to use prefabs without noticing the editor and all options available on it. Can you clarify the question?
     
  13. MorrK

    MorrK

    Joined:
    Nov 11, 2012
    Posts:
    3
    could you point me to a route to add it myself? We need this in our project and i'd love to not write the whole table thing myself i like your plugin a lot. :)
     
  14. MorrK

    MorrK

    Joined:
    Nov 11, 2012
    Posts:
    3
    ok i'll answer myself in case someone else needs it.
    I've managed to make it work even though a bit dirty.

    in my data class i've added this:

    Code (CSharp):
    1. private float leftx = 0;
    2.  
    3. void Start () {
    4.  
    5.         this.table = this.GetComponent<Table>();
    6. ...
    7. // Draw Your Table
    8.         this.table.startRenderEngine();
    9.         this.table.bodyScroller.onValueChanged.AddListener(this.onBodyScroll);
    10. }
    11.  
    12. // reset scrolling of left column
    13. void onBodyScroll (Vector2 val) {
    14.         //store x offset of first column line
    15.         if (leftx == 0) {
    16.             this.leftx = table.columnOverlayLines [0].position.x+10f;
    17.             if (table.columnOverlayLines [0].parent.name == "Content") {
    18.                 table.columnOverlayLines [0].SetParent (table.columnOverlayLines [0].parent.parent);
    19.             }
    20.         }
    21.  
    22.         //if any of column lines position is lower then the left initial one hide them so they appear behind
    23.         for(int i = 1; i < table.columnOverlayLines.Count; i++) {
    24.             RectTransform rt = table.columnOverlayLines [i];
    25.             if (rt.position.x < leftx) {
    26.                 rt.gameObject.SetActive (false);
    27.             } else {
    28.                 rt.gameObject.SetActive (true);
    29.             }
    30.         }
    31.  
    32.         //detach leftmost header cell from scrolling parent and move it up in hierarchy so it stays sticky
    33.         foreach (Cell cell in table.headerRow.cells) {
    34.             if (cell.name == "Column0") {
    35.                 if (cell.gameObject.transform.parent.name == "CanvasGroup") {
    36.                     cell.gameObject.transform.SetParent (cell.gameObject.transform.parent.parent.parent);
    37.                 }
    38.                 cell.transform.SetSiblingIndex (1);
    39.             }
    40.  
    41.         }
    42.  
    43.         //rest x position of left column cells
    44.         foreach (Row row in this.table.rows) {
    45.             foreach (Cell cell in row.cells) {
    46.                 if (cell.name == "Column0") {
    47.                     cell.GetComponent<RectTransform> ().position = new Vector2 (0f, cell.GetComponent<RectTransform> ().position.y);
    48.                     //make sure its above all other cells / rendered last
    49.                     cell.transform.SetAsLastSibling ();
    50.                 }
    51.             }
    52.         }
    53. }
    and in the Controls.cs i've replaced the line:

    Code (CSharp):
    1.         cell.rt.localPosition = new Vector3(hPos, 0);
    2.  
    with

    Code (CSharp):
    1. if (cell.name != "Column0") {
    2.     cell.rt.localPosition = new Vector3(hPos, 0);
    3. }
    4.  
     
  15. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    164
    How can I get an event when the player clicks on an icon please ?
     
  16. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    164
    I found a way using the uid.

    I do have another question about the scroll bars. I'm getting a horizontal scroll bar when one is not needed - is there a way to control that ?

    Also how can it be styled more ? Like round edges would be nice.

    It's working well though, I think it's a good buy, thank you :)
     
  17. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    164
    Actually I spoke too soon.

    This is buggy. I had it working last night and saved everything - now I come back this morning without making any alterations and it's stopped working - all I get is the revolving loading icon and no error messages - it just hangs.

    Also when I try to do a table using OnEnable it does not work either.
     
  18. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    164
    So, I started again.

    table.reset() does not seem to work.

    I have been trying to get the table to fill using OnEnable() (which breaks the input boxes) but whilst the table loads okay the first time around, any subsequent runs ruin the columns.

     
  19. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    164
    Guess what it was me :confused:

    I wasn't using 'this' ie; this.table...

    I also set up the column widths using 'Column'.

    Seems to be working now and the OnEnable() :)

    So user error, sorry 'bout that !
     
  20. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Just read through your series of posts, sounds like quite a journey. :)
    Glad you got things straightened out.
     
  21. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    164
    Haha yes, it's the classic case of spending ages trying to figure something out, posting a request for help then finding the solution five minutes later.

    Also I should RTFM :)

    Thanks though, this has come together well and I have just what I need now, so alls well that ends well.
     
  22. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    164
    OK, this time I do have an error which I can't figure out. The table loads fine, but I get this error.

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[SLS.Widgets.Table.Row].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    SLS.Widgets.Table.Control.getVerticalControl () (at Assets/SLS/Widgets/Table/Control.cs:47)
    SLS.Widgets.Table.Control.onBodyScroll (Vector2 val) (at Assets/SLS/Widgets/Table/Control.cs:166)
    SLS.Widgets.Table.Control.draw () (at Assets/SLS/Widgets/Table/Control.cs:20)
    SLS.Widgets.Table.Table.startRenderEngine () (at Assets/SLS/Widgets/Table/Table.cs:528)
    uisaves.OnEnable () (at Assets/uisaves.cs:39)

    Line 39, is just where I start the table...

    this.table.startRenderEngine();

    The table loads fine but I get that error.
     
  23. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    164
    Here's my code, it's just populating the table with filenames froma directory.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4. using System.IO;
    5. using SLS.Widgets.Table;
    6.  
    7. public class uisaves : MonoBehaviour {
    8.  
    9.     public Table table;
    10.  
    11.     // Use this for initialization
    12.     void Start () {
    13.        
    14.     }
    15.  
    16.     void OnEnable()
    17.     {
    18.         string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData).ToString() + "/Saved Games";
    19.  
    20.         DirectoryInfo directoryInfo = new DirectoryInfo(folder);
    21.         FileInfo[] fileInfo = directoryInfo.GetFiles("*.gd", SearchOption.AllDirectories);
    22.  
    23.         this.table = GetComponent<Table>();
    24.         this.table.reset();
    25.         this.table.addTextColumn();
    26.         // Initialize Your Table
    27.         this.table.initialize(this.onTableSelected);
    28.  
    29.         foreach (FileInfo file in fileInfo)
    30.         {
    31.             print(file.Name);
    32.             Datum d = Datum.Body(file.Name);
    33.             d.elements.Add(file.Name.Replace(".gd", ""));
    34.             this.table.data.Add(d);
    35.         }
    36.    
    37.         // Draw Your Table
    38.         this.table.startRenderEngine();
    39.        
    40.     }
    41.  
    42.     private void onTableSelected(Datum datum)
    43.     {
    44.         InputField fileSaveName = GameObject.Find("UISaveName").GetComponent<InputField>();
    45.         fileSaveName.text = datum.uid.Replace(".gd", "");
    46.  
    47.     }
    48.  
    49.     // Update is called once per frame
    50.     void Update () {
    51.    
    52.     }
    53. }
     
  24. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    I pasted your code in and it seems to work fine for me. I'm not seeing any errors. When you say the table loads fine but you get that error, at what time or what are you doing to get the error?
     
  25. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    164
    Various things are happening. It's during launch time. My script above and your Table script are attached to a panel - they are the only scripts running on it.

    I've found that if I removed your Table script and my script, then add them back again, the error goes away. This is without changing any code whatsoever. But it came back again after a while.
     
  26. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    164
    Hmm, an update. This has no rhyme nor reason to me. Like I said I was able to reattach the scripts and the problem went away. After working on a few other separate things later on it came back again. Same thing, table loads but there's that error.

    I saved everything as usual after doing some work, shut down Unity totally. Came back later and no error message any more.

    I can't think why it would come and go like this. What could be changing it's behaviour ?
     
  27. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Not sure, we've had hundreds of people buy the asset and you're the first that's reported this behavior. :) I'd love to get this fixed though so let's see if we can narrow it down. Starting at the most basic level, what version of Unity and our asset are your running?
     
  28. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    164
    Unity 5.3.4f1

    Your plugin ReadMe is saying : Thanks for using Table Pro (v1.009)!
     
  29. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    v1.10 of our plugin hit the Asset store a few days ago. Can you pull that and see if it behaves any differently? We squished a few bugs in that related to table reuse and whatnot... somewhat grasping at straws here but it's possible the newest version could behave better for you.
     
  30. Freddy888

    Freddy888

    Joined:
    Sep 13, 2014
    Posts:
    164
    OK I updated the asset, fingers crossed :)

    I'll let you know how it goes. Thanks for your help.
     
  31. TSI25

    TSI25

    Joined:
    Sep 22, 2013
    Posts:
    11
    I need to support multiple different row background colors and it doesn't seem like theres a good way to do that having messed with it a bit and looked through the documentation. Ideally I'd like to be able to set it when I'm initializing the datums in the table.

    I think I see an avenue to make it happen but it would require significant modification of the table code which I would rather avoid since it would make upgrading to a new version a hassle. Is there a way to do this already and I've missed it? Alternatively is there any way for this to be supported in the next version?
     
    Last edited: Aug 17, 2016
  32. TSI25

    TSI25

    Joined:
    Sep 22, 2013
    Posts:
    11
    As a follow up I decided to add the recoloring support I needed in case it would be helpful for you or others. I attempted to be consistent with the code conventions in this package but Its a lot different than how I usually code XD. These modifications were made to v1.10

    I added this to the Datum.cs class so I could programmatically assign it while initializing the cells and rows in the table (I only need a handful of rows to be recolored.)

    Code (CSharp):
    1. private Color? _backgroundColor;
    2.   public Color? backgroundColor {
    3.     get { return this._backgroundColor; }
    4.     set {
    5.         this._backgroundColor = value;
    6.         this.datum.isDirty = true;
    7.     }
    8.   }
    and then I made several minor modifications to the cell class to just check if the background color had been set. if it isnt then use the color defined in the inspector. if it was set then use that instead. I'll attach that full code below.

    There are some notable limitations that I might clean up later if it becomes a problem for my application but maybe this will serve as a decent starting point for others. The highlighting hover/select functionality will obviously set the recolored cells to be whatever the highlight values are. This solution will only recolor the cells, and not the row graphic behind them. This alternative color can only be set and accessed programmatically.
     

    Attached Files:

    • Cell.cs
      File size:
      8.5 KB
      Views:
      662
    slumtrimpet likes this.
  33. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Thank you! Yes, we're still watching the forum and the project isn't dead. I'll test and incorporate your changes into the next release. Appreciate your effort here and thanks for sharing the code!
     
  34. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    FYI... Initial testing of your cell color mod looks good on our end. I'll plan to push an update to the Asset Store next week with this change. Thanks again!
     
  35. albertchan

    albertchan

    Joined:
    Feb 4, 2016
    Posts:
    2
    I created a project exact as your example, the top, left, bottom were normal but the right side out of boundary and the horizontal bar appear also. It happened in run mode at first, the table returned to normal fit if I resize the game window manually a bit. Is there any way to fit the table inside a panel/object? Did I do anything wrong?
    Unity 5.4.1f1
     
  36. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Well.. for now what you've done wrong is posting the full source-code to our asset publicly on this forum. Please remove that attachment and send privately in the future. In the meantime, we are looking at the issue you've reported and will reply back shortly.
     
    Last edited: Sep 22, 2016
  37. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Change line 37 in MeasureMaster.cs from:
    Code (csharp):
    1.  
    2. float bodyw = this.table.bodyRect.rt.rect.width -
    3.  
    to:
    Code (csharp):
    1.  
    2. floatbodyw = this.table.root.rect.width -
    3.  
    We'll continue testing on this end, but if no issues are found this fix will be included in the next release (1.13).

    Thanks!
     
    albertchan likes this.
  38. albertchan

    albertchan

    Joined:
    Feb 4, 2016
    Posts:
    2
    It works and perfect, thanks. I'm new here, forgive me posted the whole source file. Deleted.
     
    slumtrimpet likes this.
  39. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    No problem, and no harm done. Good luck to you. :)
     
  40. mutant_nz

    mutant_nz

    Joined:
    Nov 16, 2015
    Posts:
    12
    Hi,

    I'm trying to prevent horizontal scroll occurring. If I try it on the 'Simple' example (i.e. check restrict 100% width max), initially the horizontal scroll bar is there. If I use the vertical scroll bar, the table redraws and the horizontal scroll bar disappears. Is this a bug or am I doing something wrong?

    Thanks.
     
  41. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    What version of the asset are you using? This sounds like something that was fixed a few releases back.
     
  42. mutant_nz

    mutant_nz

    Joined:
    Nov 16, 2015
    Posts:
    12
    I only just downloaded it from the Asset Store, so it will be the latest version (I can double check when I get home though)
     
  43. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Ok, if you check it out and are on the latest stuff please post a screenshot of what you are getting so I'm sure I understand.

    Here's my output when I run the "Simple" example with "Force 100% Width Min":



    Here's "Restrict 100% Width Max":


    And here's both (same as Restrict 100%):

    I don't get a horizontal scrollbar on any of them.
     
    mutant_nz likes this.
  44. mutant_nz

    mutant_nz

    Joined:
    Nov 16, 2015
    Posts:
    12
    I just upgraded to 1.13 (which I think you just released? Only just got notified of it anyway)... it fixed the problem.

    Thanks!
     
    slumtrimpet likes this.
  45. MaNiC

    MaNiC

    Joined:
    Feb 18, 2013
    Posts:
    25
    Table that in a draggable window when pixel perfect checked does not render well. It flashed when dragging and content become a mess when stop. A simple scene is attached below.
     

    Attached Files:

  46. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Hi there, thanks for the solid example case! Just pushed a fix to the Asset Store for this case. Should be available within a couple days once Unity approves it. The release version will be 1.14.



    PS.. I added your example case to our standard "Samples" directory. I'll keep this in our standard test-case set moving forward.
     
    Last edited: Oct 19, 2016
  47. MaNiC

    MaNiC

    Joined:
    Feb 18, 2013
    Posts:
    25
    Thank you for the reply in the speed of thunder :) Is there a quick way to fix this based on version 1.13?
     
  48. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Just PM'ed you a private download link. :)
     
  49. setford

    setford

    Joined:
    Oct 21, 2016
    Posts:
    4
    we bought Table Pro, got message following message, please help, thanks

    Attempting to select while already selecting an object.
    UnityEngine.UI.Selectable:set_interactable(Boolean)
    SLS.Widgets.Table.<DeactivateLater>c__Iterator1:MoveNext() (at Assets/SLS/Widgets/Table/InputCell.cs:91)
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    SLS.Widgets.Table.InputCell:RemoveFocus(Boolean) (at Assets/SLS/Widgets/Table/InputCell.cs:85)
    SLS.Widgets.Table.InputCell:OnEndEdit(String) (at Assets/SLS/Widgets/Table/InputCell.cs:40)
    UnityEngine.EventSystems.EventSystem:Update()
     
  50. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    359
    Can you please try with the latest release? We just patched this exact issue in the latest asset version.
     
unityunity