Search Unity

Bug NullRefException @ InputField.UpdateLabel()

Discussion in 'UGUI & TextMesh Pro' started by MrLucid72, Jul 17, 2020.

  1. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    985
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. TMPro.TMP_InputField.UpdateLabel () (at Library/PackageCache/com.unity.textmeshpro@3.0.0-preview.13/Scripts/Runtime/TMP_InputField.cs:3181)
    3. TMPro.TMP_InputField.SetText (System.String value, System.Boolean sendCallback) (at Library/PackageCache/com.unity.textmeshpro@3.0.0-preview.13/Scripts/Runtime/TMP_InputField.cs:575)
    4. TMPro.TMP_InputField.SetTextWithoutNotify (System.String input) (at Library/PackageCache/com.unity.textmeshpro@3.0.0-preview.13/Scripts/Runtime/TMP_InputField.cs:514)
    5. ToLSettings.InitLogsPreset () (at Assets/_Imperium42/_Scripts/UI/Settings/ToLSettings.cs:625)
    6. UnityEngine.Events.InvokableCall.Invoke () (at <fe83287b9d2c49cba7f18dc22475c71f>:0)
    7. UnityEngine.Events.UnityEvent.Invoke () (at <fe83287b9d2c49cba7f18dc22475c71f>:0)
    8. UnityEngine.UI.Button.Press () (at C:/Program Files/Unity/Hub/Editor/2020.1.0b2/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:68)
    9. UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2020.1.0b2/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:110)
    10. UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2020.1.0b2/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50)
    11. UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/Program Files/Unity/Hub/Editor/2020.1.0b2/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
    12. UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2020.1.0b2/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:374)
    13.  
    upload_2020-7-17_23-1-23.png

    I'm not quite sure what's going on here, but I'm spawning a prefab containing some input fields like a journal:
    upload_2020-7-17_23-2-32.png

    upload_2020-7-17_23-1-52.png

    If I spam click to set active it a few times, it'll finally show but not let users edit (users could previously edit). Which is a bit strange. Error indicates it's some TMPro error involving InputField when it sets active.
     
    Last edited: Jul 17, 2020
  2. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    985
    Oops, forgot to prefix title with TMPro. Ping @Stephan_B
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Be sure to test with version 3.0.0 to see if the behavior is the same.

    If the issue persists, can you provide me with some repro project or access to whatever you are using via private PM or something. Whatever is simplest for you that will allow me to reproduce the issue to resolve it.
     
    MrLucid72 likes this.
  4. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    985
  5. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    985
    Fixed with null check editing TMP src: Not sure if there are any side effects, though.


    EDIT: Ah, I need to embed the pkg or it resets.
     

    Attached Files:

    Last edited: Jul 20, 2020
  6. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    985
    @Stephan_B No rush, but just wanted to make sure you saw the workaround that may be a fix ^ Pls @ping me if you remember when it gets patched (I'm currently embedding the package with this fix, but last time I forgot I did this after a period of time went by :p would love to patch up for my future memory)
     
  7. RaRdqq

    RaRdqq

    Joined:
    Jul 29, 2018
    Posts:
    3
    Same issue here, just trying to set inputfield text from the Awake
     
  8. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    985
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    When you reference "spam click set active", you mean enabling and disabling the input field or its parent. Correct?

    I am trying to understand what leads the the textInfo of the object being null.
     
    MrLucid72 likes this.
  10. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    985
    Correct. All the button does is set the input active.
     
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I have addressed the above issue.

    The fix will be included in the next release of the TMP package.

    upload_2020-9-1_12-5-49.png

    Fix is essentially just a null check, but I also did some minor clean up while at it.
     
    Last edited: Sep 1, 2020
    KuzonDeath likes this.
  12. thadeuconstantinosantos

    thadeuconstantinosantos

    Joined:
    May 3, 2023
    Posts:
    3
    This validation fixed this problem, PLEASE, update the TMPro.

    NullReferenceException: Object reference not set to an instance of an object.

    TMPro.TMP_InputField.OnSubmit (UnityEngine.EventSystems.BaseEventData eventData) (at <00000000000000000000000000000000>:0)
     

    Attached Files: