Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]TextMeshProInputField error when set ContentType to Password #73

Open
MatrixBai opened this issue Apr 28, 2017 · 0 comments
Open

Comments

@MatrixBai
Copy link

Switched to TMP in UIExample demo, then an error pop up

[MarkLight] TextMeshProInputField: Initialize() failed. Exception thrown: Object reference not set to an instance of an object
at TMPro.TMP_InputField.UpdateLabel () [0x00000] in :0
at TMPro.TMP_InputField.SendOnValueChangedAndUpdateLabel () [0x00000] in :0
at TMPro.TMP_InputField.set_text (System.String value) [0x00000] in :0
at MarkLight.Views.UI.TextMeshProInputField.TextChanged () [0x00043] in C:\Users\blueg\Documents\Project\PluginsTestGround\Assets\MarkLight\Source\Plugins\Views\UI\TextMeshPro\TextMeshProInputField.cs:471
at MarkLight.Views.UI.TextMeshProInputField.Initialize () [0x00060] in C:\Users\blueg\Documents\Project\PluginsTestGround\Assets\MarkLight\Source\Plugins\Views\UI\TextMeshPro\TextMeshProInputField.cs:458
at MarkLight.View.TryInitialize () [0x00003] in C:\Users\blueg\Documents\Project\PluginsTestGround\Assets\MarkLight\Source\Plugins\View.cs:1703
UnityEngine.Debug:LogError(Object)
MarkLight.View:TryInitialize() (at Assets/MarkLight/Source/Plugins/View.cs:1707)
MarkLight.ViewPresenter:m__2(View) (at Assets/MarkLight/Source/Plugins/ViewPresenter.cs:128)
MarkLight.c__AnonStorey01:<>m__0(View) (at Assets/MarkLight/Source/Plugins/ExtensionMethods.cs:194) MarkLight.ExtensionMethods:DoUntil(View, Func2, Boolean, View, TraversalAlgorithm) (at Assets/MarkLight/Source/Plugins/ExtensionMethods.cs:177)
MarkLight.ExtensionMethods:DoUntil(View, Func2, Boolean, View, TraversalAlgorithm) (at Assets/MarkLight/Source/Plugins/ExtensionMethods.cs:172) MarkLight.ExtensionMethods:ForEachChild(View, Action1, Boolean, View, TraversalAlgorithm) (at Assets/MarkLight/Source/Plugins/ExtensionMethods.cs:194)
MarkLight.ExtensionMethods:ForThisAndEachChild(View, Action1, Boolean, View, TraversalAlgorithm) (at Assets/MarkLight/Source/Plugins/ExtensionMethods.cs:207) MarkLight.ViewPresenter:InitializeViews(View) (at Assets/MarkLight/Source/Plugins/ViewPresenter.cs:128) MarkLight.ViewPresenter:InitializeViews(GameObject) (at Assets/MarkLight/Source/Plugins/ViewPresenter.cs:109) MarkLight.ViewPresenter:Initialize() (at Assets/MarkLight/Source/Plugins/ViewPresenter.cs:98) MarkLight.ViewData:GenerateViews() (at Assets/MarkLight/Source/Plugins/ViewData.cs:97) MarkLight.ViewData:LoadAllXuml(IEnumerable1) (at Assets/MarkLight/Source/Plugins/ViewData.cs:117)
MarkLight.Editor.ViewPostprocessor:ProcessViewAssets() (at Assets/MarkLight/Source/Plugins/Editor/ViewPostprocessor.cs:90)
MarkLight.Editor.ViewPresenterInspector:OnInspectorGUI() (at Assets/MarkLight/Source/Plugins/Editor/ViewPresenterInspector.cs:118)
UnityEditor.DockArea:OnGUI()

After some checking, the error is caused by sending a null string to TMP_InputField

public void TMProInputFieldValueChanged(string value)
        {
            if (!SetValueOnEndEdit)
            {
                //1.This line set Text.Value to null
                Text.Value = TextMeshProInputFieldComponent.text;
            }

            TMProUpdatePlaceholder();
            ValueChanged.Trigger();
        }

    public override void TextChanged()
    {
            if (OnlyTriggerValueChangedFromUI)
            {
                TextMeshProInputFieldComponent.onValueChanged.RemoveAllListeners();
            }
            //2.Text.Value is null caused the error
            TextMeshProInputFieldComponent.text = Text ?? String.Empty;

            if (OnlyTriggerValueChangedFromUI)
            {
                TextMeshProInputFieldComponent.onValueChanged.AddListener(TMProInputFieldValueChanged);
                TMProUpdatePlaceholder();
            }
}

There's no error when removing ContentType field of input field in xml.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant