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

InputField Visibility trouble #51

Closed
KornyAS opened this issue Nov 20, 2020 · 9 comments
Closed

InputField Visibility trouble #51

KornyAS opened this issue Nov 20, 2020 · 9 comments

Comments

@KornyAS
Copy link

KornyAS commented Nov 20, 2020

I have a bug: my Plugin object locate in my global obj and after run - he become DontDestroyOnLoad's object, it's all right, but my InputField object locate in other object, for instance "Ghoul" which is inactive from the start, when I open this "Ghoul" it's also all right, it works perfectly.
Thing is, when I close this Ghoul and switch from my app to youtube, for instance, and switch back to my app and enable Ghoul - I saw that no InputField exist because he is still invisible. It's impossible to fix this by enabling/disabling Ghoul or any other object. But when I close Ghoul and switch my app to youtube again, switch back and enable Ghoul - InputField become visible again. How it can be fixed? I have no idea, when I tried to check in Update the visibility state - I saw false, but InputField was visible. I have to this bug be fixed as soon as possible.
Help me please....

@KornyAS
Copy link
Author

KornyAS commented Nov 21, 2020

  • Noticed just right now that if you open notification panel - InputField will dissapear and you have to disable and enable InputField parent to make it visible. But it happens very rarely.

@mopsicus
Copy link
Owner

There are many different cases with visibility, so you have to control visibility of inputfields by yourself. When application lost focus hide it and show when it return to user. There are special method for that SetVisible.

@KornyAS
Copy link
Author

KornyAS commented Nov 21, 2020

Yes, I tried, I tried also make it visible in Update but unsuccessfully. It just stay invisible while I execute SetVisible(true) in Update.

@KornyAS
Copy link
Author

KornyAS commented Nov 23, 2020

So, any idea how to fix it?

@mopsicus
Copy link
Owner

I don't know..
I guess, this is architecture issue of your app, and no plugin

@KornyAS
Copy link
Author

KornyAS commented Nov 26, 2020

SOLVED

If someone has the same bug, try to replace method OnEnable() from

private void OnEnable () {
    if (_isMobileInputCreated) {
        this.SetVisible (true);
    }
}

to

private void OnEnable () {
    base.Start();
    StartCoroutine(InitialzieOnNextFrame());
}

and also replace method OnDisable() from

private void OnDisable() {
    if (_isMobileInputCreated) {
        this.SetFocus (false);
        this.SetVisible (false);
    }
}

to

private void OnDisable() {
    RemoveNative();
}

It will work for everyone, just make sure that you make _inputObjectText.FontSize multiplication by ratio just once.
For instance, create a bool variable and make like this:

if (isFirstTime) {
    isFirstTime = false;
    _config.FontSize = ((float)_inputObjectText.fontSize) * ratio;
} else {
    _config.FontSize = ((float)_inputObjectText.fontSize);
}

@Shantibhushan95
Copy link

Had same issue with DontDestroyOnLoad UI panels. @Almazikman's solution worked, but the overlay inputfield wasn't disappearing when I closed the panel after opening it more than once in different scenes. I added following public member which is called only for DontDestroyOnLoad panels, this is working now.

public void SetCustomVisibilityOff()
{
	if (_isMobileInputCreated)
	{
		this.SetFocus(false);
		this.SetVisible(false);
		RemoveNative();
	}
}

@ajathunity3d
Copy link

Had same issue with DontDestroyOnLoad UI panels. @Almazikman's solution worked, but the overlay inputfield wasn't disappearing when I closed the panel after opening it more than once in different scenes. I added following public member which is called only for DontDestroyOnLoad panels, this is working now.

public void SetCustomVisibilityOff()
{
	if (_isMobileInputCreated)
	{
		this.SetFocus(false);
		this.SetVisible(false);
		RemoveNative();
	}
}

From where you're calling this method??

@Shantibhushan95
Copy link

I added this method as a public member of MobileInputField.cs and am calling the method from a script attached to the DontDestroyOnLoad ui panels containing an inputfield whenever the panel needs to be closed.

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

4 participants