Skip to content

NullReferenceException in CommandInputField's ctor on Unity 6000.6 (uGUI 2.6.0) #119

Description

@skycaaf

Description of the bug
On Unity 6000.6.0f1 (ships with com.unity.ugui 2.6.0), a NullReferenceException is thrown from CommandInputField's constructor every time the component is deserialized — e.g., each time the Editor restores the last opened scene that contains the IngameDebugConsole prefab at startup.

The field initializer at CommandInputField.cs:60 reflects TMP_InputField's private field m_IsCompositionActive:

private readonly FieldInfoGetDelegate m_IsCompositionActiveGetter = typeof(TMP_InputField).GetField("m_IsCompositionActive", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).GetValue;

In uGUI 2.6.0's TMP_InputField, this field no longer exists (composition handling was refactored to compositionString/compositionLength properties), so GetField returns null and dereferencing .GetValue throws. There is no null-check. I verified in my project's Library/PackageCache/com.unity.ugui@23caec89ae27/Runtime/TMP/TMP_InputField.cs that m_IsCompositionActive is absent, while m_IsTextComponentUpdateRequired still exists (so only the getter is currently affected).

I searched Issues and the FAQ and couldn't find this reported. Verified that both the latest release (v1.8.9) and the current master branch contain the affected line.

Reproduction steps

  1. Create or open a project on Unity 6000.6.0f1 (Package Manager shows com.unity.ugui 2.6.0).
  2. Import In-game Debug Console v1.8.9 from the Asset Store.
  3. Add the IngameDebugConsole prefab to a scene and save it.
  4. Restart the Unity Editor (or reopen/reload the scene).
  5. The Console shows NullReferenceException: Object reference not set to an instance of an object pointing at CommandInputField.cs:60, thrown during EditorSceneManager.LoadLastSceneManagerSetup(). Reopening the scene reproduces it again. Since the exception is thrown in the constructor itself, any deserialization/instantiation of the component triggers it.

Platform specs

  • Unity version: 6000.6.0f1 (f7f8ed4d1e24)
  • Platform: Windows Editor
  • Device: Windows 11 Pro (10.0.26200)
  • How did you download the plugin: Asset Store (v1.8.9)

Additional info
Full stack trace from the Editor.log:

NullReferenceException: Object reference not set to an instance of an object.
  at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_ldvirtfn(object,intptr)
  at IngameDebugConsole.CommandInputField..ctor () [0x0003d] in <project path>\Assets\Plugins\IngameDebugConsole\Scripts\CommandInputField.cs:60
UnityEngine.Serialization.SerializationBackendManagedCommands:ReadUnityObjectFromBuffer(IntPtr, IntPtr, IntPtr, Int32, IntPtr, IntPtr)
UnityEngine.Serialization.SerializationBackendManagedCommands:ExecuteReadCommands(NativeReadBufferContext*, Byte&, Byte*, Int32, IntPtr, Int32&)
UnityEngine.Serialization.SerializationBackendManagedCommands:SerializationBufferToObject(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
UnityEditor.SceneManagement.EditorSceneManager:LoadLastSceneManagerSetup()
UnityEditor.EditorApplication:Internal_RestoreLastOpenedScenes()

(Filename: Assets/Plugins/IngameDebugConsole/Scripts/CommandInputField.cs Line: 60)

A second NRE appears alongside while the scene is restored (possibly fallout from the constructor failing mid-deserialization, mentioning for completeness):

NullReferenceException: Object reference not set to an instance of an object
  at UnityEngine.UI.Selectable.ParentGroupAllowsInteraction () [0x0005a] in .\Library\PackageCache\com.unity.ugui@23caec89ae27\Runtime\UGUI\UI\Core\Selectable.cs:456
  at UnityEngine.UI.Selectable.OnCanvasGroupChanged () [0x00000] in .\Library\PackageCache\com.unity.ugui@23caec89ae27\Runtime\UGUI\UI\Core\Selectable.cs:441
UnityEditor.SceneManagement.EditorSceneManager:LoadLastSceneManagerSetup()
Image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions