Author Topic: UIInput WINRT  (Read 13388 times)

mmalek

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
UIInput WINRT
« on: October 05, 2014, 04:05:24 PM »
I purchased NGUI from the asset store about a month ago. I have been having issues with the UIInput.cs control on Windows 8.1. Same control works as expected on Windows Phone 8.

When touching the control on Windows 8.1 it seems like OnSelect does not always get called from UICamera.

On Windows phone the same UIInput.cs code is working as expected. Keyboard pops up, edit and backspace seem to work fine. On Windows 8.1 the UIInput.cs default code seems to lose focus, intermittently (every 20 or so touches) bring up the onscreen keyboard and gains focus, and backspace also does not work when focus is gained.

I made sure the UIInput control is top in the window level hierarchy. (Level 20)

I have tried a few things to get things working better-

I upgraded recently to NGUI 3.7.4 (issue was occurring before and after).

Added UNITY_WINRT || UNITY_METRO to the defines at the top for MOBILE (redundant as it may be)

For troubleshooting- I made some changes or commented out some of the UNITY_METRO specific code as it is making some items not function as expected-
Line 222-
public bool inputShouldBeHidden
{
   get
   {
#if UNITY_METRO
      return false; //Changed from true as do not want to hide input for Windows 8
#else
      return hideInput && label != null && !label.multiLine && inputType != InputType.Password;
#endif
   }
}


Line 618-
//#if UNITY_METRO
//                  val = "";
//#else
                  val = "|";
//#endif

Line 666-
// #if UNITY_METRO
//            string text = Input.inputString;
//            if (!string.IsNullOrEmpty(text)) Insert(text);
// #else

Line 640-
For troubleshooting just took some variables out of the mix as it is for username-
                    mKeyboard = TouchScreenKeyboard.Open(val, kt, true, false, false, false, defaultText);
                    //mKeyboard = (inputType == InputType.Password) ?
                    //    TouchScreenKeyboard.Open(val, kt, false, false, true) :
                    //    TouchScreenKeyboard.Open(val, kt, !inputShouldBeHidden && inputType == InputType.AutoCorrect,
                    //        label.multiLine && !hideInput, false, false, defaultText);

With the above changes in Windows 8.1, I am able to initially select, have keyboard popup, and edit (including backspace) the UIInput (in may case username edit control).

If I deselect (touch somewhere else on the screen) and try to come back to edit the it takes 20 or so touches to regain focus and have the keyboard pop back up.

I have been troubleshooting for a few days and need your help. Any help will be much appreciated. I have Skype available if you want.

Thank you!
Mark




« Last Edit: October 05, 2014, 05:37:34 PM by mmalek »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput WINRT
« Reply #1 on: October 06, 2014, 10:07:31 AM »
Generally if something works on one version of OS but not on the other, it's a Unity bug. NGUI certainly doesn't differentiate between different OS versions, and while the UIInput has a lot of #if <platform> hacks, none involve different versions. I would suggest submitting a bug to Unity.

mmalek

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UIInput WINRT
« Reply #2 on: October 06, 2014, 11:13:39 AM »
Thank you for the reply Aren!

I would agree with you, but the issue is intermittent. The OnSelect does eventually get called (after tapping many times), the label does gain focus, the onscreen keyboard does eventually popup and the editing does work.
After debugging for a few days it appears to be definitely something either in OnCamera or UIInput.

I agree, the issue is not OS Version specific, it is Platform specific- I was comparing Windows Phone (working) with Windows 8 (Not working- UIInput intermittently gaining focus).

There are differences in the code based on UNITY_METRO.

I realize you are extremely busy, I am happy to assist you in anyway possible.

Thank you in advance!
Mark
« Last Edit: October 06, 2014, 11:23:40 AM by mmalek »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput WINRT
« Reply #3 on: October 07, 2014, 09:57:03 AM »
Create a simple test case where you check for Input.GetTouch, do a raycast that hits a 3D cube in the scene, and if it hits it -- changes its color. When the touch is released, change the color back.

NGUI does exactly this, minus the color change. If you see issues with that example, then you can submit it to Unity for fixing.

mmalek

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UIInput WINRT
« Reply #4 on: October 07, 2014, 11:46:16 AM »
Hello Aren,

Thank you for the suggestion.
A little more background-
I have 4 different NGUI buttons, a couple of NGUI checkboxes, some NGUI Sliders bars, and a single NGUI "Simple Input Field" on the same NGUI Sprite background. Every NGUI button and NGUI check box, NGUI slider bar, respond to touch without hesitation. It is limited solely to the NGUI "Simple Input Field" (UIInput) intermittently receiving the OnSelect event (gain focus) when touched.

Thank you!
Mark

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput WINRT
« Reply #5 on: October 08, 2014, 01:03:15 PM »
Have you tried NGUIDebug.Log printing the selected state in OnSelect attached to buttons / input?

roberto_sc

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: UIInput WINRT
« Reply #6 on: October 09, 2014, 02:10:15 PM »
I'm experiencing the same problem.

Quote
Generally if something works on one version of OS but not on the other, it's a Unity bug

I just want to make sure I'm in the same page as you guys: it works on Windows Phone 8 and not on Windows 8.1 (for PC). They are not different versions of the same OS, they are differents OS.

@mmalek, did you manage to get it working?

roberto_sc

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: UIInput WINRT
« Reply #7 on: October 09, 2014, 08:58:51 PM »
Removing UNITY_WINRT from the MOBILE define, did it for me, after all UNITY_METRO is not mobile :)

UNITY_WINRT == UNITY_METRO || UNITY_WP8

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput WINRT
« Reply #8 on: October 10, 2014, 02:44:33 AM »
It may not be mobile, but it can have touch screen input and on-screen keyboard, which is why it's a part of that define. But... if having it there causes some glitches, I can remove it.

mmalek

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UIInput WINRT
« Reply #9 on: October 10, 2014, 07:57:17 PM »
Agreed Aren. The onscreen keyboard needs to be able to popup when the user touches the Simple Edit Control.

I tried removing the "UNITY_WINRT - MOBILE" define and checked which functionalities work-
1) Simple Edit Control OnSelect appears to work consistently
2) Popup keyboard does not happen
3) Backspace functionality does not work (after bringing the onscreen keyboard up manually)

With UNITY_WINRT - MOBILE define
1) Broken- Edit control selection is inconsistent- happens infrequently
2) Working- When selection does happen the keyboard does popup
3) Working- The backspace functionality works
With a few changes I have #2 and #3 working. Just need to get #1 figured out.

I will continue to look at #1 this weekend.

Thank you!

« Last Edit: October 10, 2014, 08:23:20 PM by mmalek »

dant

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UIInput WINRT
« Reply #10 on: October 15, 2014, 12:28:58 AM »
Hi,

Just wanted to add my voice to this thread as I'm having the exact same issue. If I tap the input box right away it works but if I click away and come back, I can't enter text. It does seem to get focus as the cursor is there it doesn't get anything from the keyboard.

Thanks,
-Dan

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput WINRT
« Reply #11 on: October 16, 2014, 05:51:44 AM »
It's best to choose the events on the UICamera that you need -- for example on touch devices, leave touch on but mouse off. On mouse-using devices, use mouse, but disable touch.

Meltdown

  • Jr. Member
  • **
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 56
    • View Profile
Re: UIInput WINRT
« Reply #12 on: October 27, 2014, 06:36:19 PM »
I'm having similar issues with NGUI 3.7.5

The only way I've gotten the virtual keyboard to work is to include UNITY_METRO as part of the MOBILE define, and uncheck the 'Mouse' in process events on UICamera.

It seems to work well on the first touch, and the keyboard appears. But if it loses focus, then you tap on the UIInput again, the keyboard only seems to appear if you touch with 2 fingers  :o
« Last Edit: October 27, 2014, 07:11:27 PM by Meltdown »

Meltdown

  • Jr. Member
  • **
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 56
    • View Profile
Re: UIInput WINRT
« Reply #13 on: October 27, 2014, 07:21:56 PM »
Ok, good news, I've created a hack for the keyboard not showing up the second time...  8)

You need to change OnSelectEvent, and OnDeselectEvent to an IEnumerator and put in a small yield at the beginning...

  1. IEnumerator OnSelectEvent ()
  2.         {
  3.             yield return new WaitForSeconds(0.1f);
  4.  
  5. IEnumerator OnDeselectEvent ()
  6.         {
  7.             yield return new WaitForSeconds(0.1f);

This works with all event processes selected on UICamera as well :)

As mentioned above, you also need to modify the mobile define to the following...

  1. #if !UNITY_EDITOR && (UNITY_IPHONE || UNITY_ANDROID || UNITY_WINRT || UNITY_BLACKBERRY)
  2. #define MOBILE
  3. #endif

Backspace still doesn't seem to work correctly though :(
« Last Edit: October 27, 2014, 07:51:31 PM by Meltdown »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput WINRT
« Reply #14 on: October 29, 2014, 05:05:21 AM »
Yay, more UIInput hacks...