Search Unity

Table Pro: When Your Data isn't a Game

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

  1. RelStrat

    RelStrat

    Joined:
    Oct 13, 2022
    Posts:
    3
    More of an annoyance than a bug... I get this error a LOT in the console window although everything still does seem to work. Typically when the application isn't actually running like between stopping and starting stc. Doesn't matter if I'm using your demo code right out of the box. Always happens, and I like to have a clean console. Any ideas?

    NullReferenceException: Object reference not set to an instance of an object
    SLS.Widgets.Table.Table.SetLayoutHorizontal () (at Assets/SLS/Widgets/Table/Table.cs:947)
    UnityEngine.UI.LayoutRebuilder+<>c.<Rebuild>b__12_1 (UnityEngine.Component e) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Layout/LayoutRebuilder.cs:86)
    UnityEngine.UI.LayoutRebuilder.PerformLayoutControl (UnityEngine.RectTransform rect, UnityEngine.Events.UnityAction`1[T0] action) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Layout/LayoutRebuilder.cs:128)
    UnityEngine.UI.LayoutRebuilder.Rebuild (UnityEngine.UI.CanvasUpdate executing) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Layout/LayoutRebuilder.cs:86)
    UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/CanvasUpdateRegistry.cs:181)
    UnityEngine.UI.ScrollRect:LateUpdate() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/ScrollRect.cs:834)
     
  2. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    The table engine uses a bunch of coroutines to do it's magic. Those get a bit squirrely when the object is deactivated and reactivated without being re-initialized. When you say it's between stopping and starting, are you talking about your actual unity program stopping and starting?

    What version of Unity are you using?
     
  3. RelStrat

    RelStrat

    Joined:
    Oct 13, 2022
    Posts:
    3
    Never mind I found the problem while trying to reproduce it. Whenever it happens I have the app playing (forgetting to stop it first) and then I edit a script, which reloads assemblies and shows the error. Thanks for the reply. :)
     
  4. BLxSug

    BLxSug

    Joined:
    Sep 13, 2019
    Posts:
    9
    Hi there,
    I'm using Table pro and I would like check input from user.
    So I came with this code
    (I want to make sure the string entered is a parsable to float, if not, put the old value back)

    Code (CSharp):
    1. private void OnInputFieldChange(Datum d, Column c, string oldVal, string newVal)
    2.     {
    3.         //parse missed
    4.         if (!float.TryParse (newVal, out float value))
    5.         {
    6.             d.elements[c.idx].value = oldVal;
    7.         }
    8.         //parse succeed
    9.         else
    10.         {
    11.             d.elements[c.idx].value = value.ToString();
    12.         }
    13.     }
    But it look like this is not working... Could you give an int for that ?
    The code is well triggered and the value are normal, but the value is not changed, or at least, is not visually update.
    Thanks ! =)
     
  5. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    If you access the datum list on the table object directly, your syntax does work. I suspect your
    Code (CSharp):
    1. Datum d
    input arg here is dereferenced somehow from the actual table.data array.

    i.e. this does work so I think you are super close but please make sure your method arg is literally the datum from the table:
    Code (CSharp):
    1. table.data[ridx].elements[cidx].value = 'newval'
     
  6. BLxSug

    BLxSug

    Joined:
    Sep 13, 2019
    Posts:
    9
    Thanks for your fast answer !
    So, I tried this way :
    Code (CSharp):
    1. private void OnInputFieldChange(Datum d, Column c, string oldVal, string newVal)
    2.     {
    3.         //parse missed
    4.         if (!float.TryParse (newVal, out float value))
    5.         {
    6.             this.table.data.First(x => x.uid == d.uid).elements[c.idx].value = oldVal;
    7.         }
    8.         //parse succeed
    9.         else
    10.         {
    11.             this.table.data.First(x => x.uid == d.uid).elements[c.idx].value = value.ToString();
    12.         }
    13.     }
    But it does work better.
    My init look this way :
    Code (CSharp):
    1. this.table.ResetTable();
    2.         // Define our columns
    3.         Column c;
    4.        
    5.  
    6.         c = this.table.AddInputColumn(OnInputFieldChange, "Offset", null, -1, 100);
    7.         c.horAlignment = Column.HorAlignment.LEFT;
    8.  
    9.         c = this.table.AddTextColumn("Real pressure", null, -1, 100);
    10.         c.horAlignment = Column.HorAlignment.LEFT;
    11.  
    12.         c = this.table.AddTextColumn("Module", null, -1, 100);
    13.         c.horAlignment = Column.HorAlignment.LEFT;
    14.  
    15.         c = this.table.AddTextColumn("Last calibration", null, -1, 125);
    16.         c.horAlignment = Column.HorAlignment.LEFT;
    17.  
    18.         // Initialize Your Table
    19.         this.table.Initialize(this.OnTableSelectedWithCol, this.spriteDict, true, this.OnHeaderClick);
    20.  
    21.  
    22.  
    23.         // Draw Your Table
    24.         this.table.StartRenderEngine();
    It look pretty much like the code you provide in exemple (AutoUpdatingAll.cs)
    I'm missing something ? =/
     
  7. slumtrimpet

    slumtrimpet

    Joined:
    Mar 18, 2014
    Posts:
    372
    Forgive the stupid question here (I'm now just guessing and trying to be helpful), but have you tested console messages to make sure your if/else in your parser function is working as expected?

    What I mean is, maybe make sure when you think the table update isn't working that it's REALLY not working and not just your if/else confusing things and leaving the value unchanged. I can't really guess anything else that you'd be doing wrong.
     
  8. BLxSug

    BLxSug

    Joined:
    Sep 13, 2019
    Posts:
    9
    No offense ^^
    I think I found the issue, here is the code :
    Code (CSharp):
    1. private void OnInputFieldChange(Datum d, Column c, string oldVal, string newVal)
    2.     {
    3.         this.table.data[0].elements[c.idx].value = "PING";
    4.         Debug.Log("Ping");
    5.         for(int i = 0; i < this.table.data.Count; i++) {
    6.             if (this.table.data[i].uid == d.uid )
    7.             {
    8.                 this.table.data[i].elements[c.idx].value = "PONG";
    9.                 this.table.data[i-1].elements[c.idx].value = "TOE";
    10.                 Debug.Log("PONG");
    11.                 break;
    12.             }
    13.         }
    14.         //this.table.data.First(x => x.uid == d.uid).elements[c.idx].value = "tralala";
    15.         Debug.Log("trigged");
    16.        
    17.     }
    Output :
    Ping
    Pong
    Trigged

    And visually :
    1st element of the tab goes "PING"
    Element -1 goes "TOE"
    and Element goes not "PONG" but stay the same as manually.
    My guess is : we can't modify the element.value of an element called this way =/ (a routine transform it afterhand maybe ?)
    What do you think ?
     
  9. BLxSug

    BLxSug

    Joined:
    Sep 13, 2019
    Posts:
    9
    Tested more :
    Code (CSharp):
    1. private void OnInputFieldChange(Datum d, Column c, string oldVal, string newVal)
    2.     {
    3.         this.table.data[0].elements[c.idx].value = "PING";
    4.         StartCoroutine(MajElement(d.elements[c.idx], "TIC"));
    5.  
    6.     }
    7.     private IEnumerator MajElement(Element e, string value)
    8.     {
    9.         yield return new WaitForSeconds(0.5f);
    10.         e.value = value;
    11.     }
    This work, the waitforseconds delay and the update of the data is not crushed / erase.
    Maybe this could be better.
    I saw no exemple provided mimicking my case.
    Anyway, thanks for your help, I'll keep it like this for now, let me know if you make update for make this work another way =)
     
    Last edited: Jul 18, 2023
    slumtrimpet likes this.