Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: rav3n256 on April 28, 2013, 04:43:27 AM

Title: UIInput + Mac web player build issue
Post by: rav3n256 on April 28, 2013, 04:43:27 AM
I've been building a web player build using ngui 2.5.1 and everything is working properly.  When I tried on a mac book running mountain lion, I'm still able to input text, but the backspace doesn't work at all.  I'm running the build on safari with a web player build that was built using unity 4.1.2f1.  Has anyone else had this issue?  Also, any suggestion to fix this.  If more information is needed, I'm happy to provide it.

Cheers
Title: Re: UIInput + Mac web player build issue
Post by: ArenMook on April 28, 2013, 04:57:48 AM
It's a bug in Unity.
Title: Re: UIInput + Mac web player build issue
Post by: rav3n256 on April 28, 2013, 05:07:52 AM
Well, that sucks.  Is there any way to get around this for now till unity decides to fix this?
Title: Re: UIInput + Mac web player build issue
Post by: ArenMook on April 28, 2013, 05:30:25 AM
None I am aware of.
Title: Re: UIInput + Mac web player build issue
Post by: marasto on May 17, 2013, 04:11:50 AM
Hi,

do you know if that issue will be fixed soon or not ?
in the meanwhile could I suggest as a workaround to map a combination like ctrl+b or cmd+b to mimic the backspace behavior ? (potentially customizable in UICamera) ?
Title: Re: UIInput + Mac web player build issue
Post by: ArenMook on May 17, 2013, 05:41:23 AM
The more bugs you submit on the issue, the faster it will get fixed... that's all I know.

Building with an earlier version of Unity, such as 3.5.7 also doesn't exhibit this issue.
Title: Re: UIInput + Mac web player build issue
Post by: marasto on May 17, 2013, 08:19:20 AM
Hi,

I had post on another thread a potential workaround. If Arenmock would like to give that a try it could be great. However I honestly prefer that  Unity guys fix that issue
Title: Re: UIInput + Mac web player build issue
Post by: marasto on May 17, 2013, 09:00:07 AM
Hot fix workaround (tested on OSX, if someone would like to check on windows is more than welcome).
All the fixes are in UICamera.cs
Hope that help

ciao!!

  1. private string lastInputEvents = System.String.Empty;
  2.  
  3. void OnGUI ()
  4.         {
  5. #if UNITY_EDITOR
  6.                 if (debug && lastHit.collider != null)
  7.                 {
  8.                         GUILayout.Label("Last Hit: " + NGUITools.GetHierarchy(lastHit.collider.gameObject).Replace("\"", ""));
  9.                 }
  10. #endif
  11. #if UNITY_WEBPLAYER
  12.                 if(inputHasFocus && (Input.imeCompositionMode != IMECompositionMode.Off)) {
  13.                         //get last reported input                      
  14.                         if(Event.current.isKey ) {
  15.                                 if(Event.current.keyCode == KeyCode.Backspace) {
  16.                                         //CHECK IF BACKSPACE IS ALREADY IN THE INPUT STRING
  17.                                         if(Input.inputString.LastIndexOf('\b') == -1) {
  18.                                                 //backspace or delete not reported so add the backspace char for the next update
  19.                                                 lastInputEvents += '\b';                                               
  20.                                         }
  21.                                 }
  22.                         }
  23.                 }
  24. #endif
  25.         }
  26.  


Update() method

  1. ...
  2. ...
  3. ...
  4.  
  5. // Forward the input to the selected object
  6.                 if (mSel != null)
  7.                 {
  8.                         string input = Input.inputString;
  9.                         //Merge the input string. Backspace always come first and the other characters
  10.                         //if the backspace is found in the current string no \b will be added so in practicve lastInputEvents will be always empty
  11.                         //if no backspace is found and a backspace has been reported, this will be added to lastInputEvents
  12.                         //next update the string will be notified and changed
  13.                         lastInputEvents += input;
  14.  
  15.                         // Adding support for some macs only having the "Delete" key instead of "Backspace"
  16.                         if (useKeyboard && Input.GetKeyDown(KeyCode.Delete) && lastInputEvents.LastIndexOf('\b') == -1) lastInputEvents += '\b';
  17.                        
  18.                         if(lastInputEvents.Length > 0)
  19.                         {
  20.                                 if (!stickyTooltip && mTooltip != null) ShowTooltip(false);
  21.                                 Notify(mSel, "OnInput", lastInputEvents);
  22.                                 //Nullify all the inputs
  23.                                 lastInputEvents = System.String.Empty;
  24.                         }
  25.                 }
  26.                 else {
  27.                         inputHasFocus = false;                 
  28.                 }
  29.  

selectObject property

  1. ...
  2. ...
  3. ...
  4. mSel = value;
  5. //reset the last reported keys events
  6. current.lastInputEvents = System.String.Empty;
  7.  
  8. ...
  9. ...
  10. ...
  11.  
Title: Re: UIInput + Mac web player build issue
Post by: erick_zeppelin on May 17, 2013, 11:41:43 AM
Thanks marasto, that works  :D

I reported this bug to Unity, waiting to fix it.
Title: Re: UIInput + Mac web player build issue
Post by: rterranova on May 23, 2013, 10:55:06 AM
In the last section of code under "selectObject property" do those lines of code in the Update function also?  At the bottom of Update?
Title: Re: UIInput + Mac web player build issue
Post by: rterranova on May 23, 2013, 11:18:07 AM
NM, I figured it out!
Title: Re: UIInput + Mac web player build issue
Post by: rterranova on May 23, 2013, 11:44:38 AM
Ok, maybe I spoke to soon.  Im getting multiple delete message when hitting the delete key.  This causing the mulitple characters to be deleted at one time. 

I put these lines

mSel = value;
//reset the last reported keys events
current.lastInputEvents = System.String.Empty;

in the selectObject set function.  But I get a null object error on the current.lastInputEvents line.

This happens on the Unity Editor

Any help would be great!
Title: Re: UIInput + Mac web player build issue
Post by: Dougomite on May 30, 2013, 11:59:24 AM
Looks like the formatting got a bit messed up. That 'current' is part of the above comment.

  1. mSel = value;
  2. //reset the last reported keys events current.
  3. lastInputEvents = System.String.Empty;

That looks to be correct.
Title: Re: UIInput + Mac web player build issue
Post by: pmerlaud on June 05, 2013, 03:49:12 AM
Hi all,

I had the same issue and got something working using the hotfix posted by marasto.

First, instead of declaring
  1. private string lastInputEvents = System.String.Empty;
I had to declare it as
  1. private static string lastInputEvents = System.String.Empty;
(otherwise I had an error "An object reference is required to access non-static member `UICamera.lastInputEvents`")

I was also getting multiple deletes using the Unity Editor, so I put the #if UNITY_WEBPLAYER ... #endif section of code (in the OnGUI function) in an if condition to check if the runtime platform is the OSX Web Player. OnGUI() now looks like :
  1. void OnGUI ()
  2.     {
  3. #if UNITY_EDITOR
  4.         if (debug && lastHit.collider != null)
  5.         {
  6.             GUILayout.Label("Last Hit: " + NGUITools.GetHierarchy(lastHit.collider.gameObject).Replace("\"", ""));
  7.         }
  8. #endif
  9.                
  10. #if UNITY_WEBPLAYER
  11.                 if(Application.platform == RuntimePlatform.OSXWebPlayer)
  12.                 {
  13.                 if(inputHasFocus && (Input.imeCompositionMode != IMECompositionMode.Off)) {
  14.                     //get last reported input                  
  15.                     if(Event.current.isKey ) {
  16.                         if(Event.current.keyCode == KeyCode.Backspace) {
  17.                             //CHECK IF BACKSPACE IS ALREADY IN THE INPUT STRING
  18.                             if(Input.inputString.LastIndexOf('\b') == -1) {
  19.                                 //backspace or delete not reported so add the backspace char for the next update
  20.                                 lastInputEvents += '\b';                                               
  21.                             }
  22.                         }
  23.                     }
  24.                 }
  25.        
  26.             }
  27. #endif
  28.         }

It's working like a charm now !
Title: Re: UIInput + Mac web player build issue
Post by: ArenMook on June 06, 2013, 11:15:36 AM
Just a quick note, Jonas fixed this properly on the Unity's side, so you will see it fixed in a later version of Unity.
Title: Re: UIInput + Mac web player build issue
Post by: vallcrist on July 25, 2013, 01:38:50 PM
Any idea if 4.2 fixed this?
Title: Re: UIInput + Mac web player build issue
Post by: CWolf on July 26, 2013, 05:55:20 AM
I didn't see any mention of this fixed in the 4.2 release notes.  Pretty annoying issue for our Mac users, sadly.  I haven't upgraded yet though so it may be in 4.2.
Title: Re: UIInput + Mac web player build issue
Post by: DarkMagicCK on February 26, 2014, 01:13:23 AM
Some info here, if you use fullscreen on osxwebplayer, the input seems correct, including backspace, tab and all else except ESC for exit fullscreen mode.
But I even can not receive Input.GetKeyDown if not using fullscreen Mode, really sucks.