Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: wizardsmoke on February 18, 2014, 12:25:30 PM

Title: Changes to UIPanel alpha do not affect alpha of UIInput caret/selection
Post by: wizardsmoke on February 18, 2014, 12:25:30 PM
I came across this issue when I selected an input field on a panel with alpha = 0 and then tweened the panel's alpha to 1.  The cursor was invisible until the next call to UIInput.UpdateLabel(), which is not called until the user either starts typing or manually reselects the input field.  This is confusing to the user because they are not aware that the input field is selected.
Title: Re: Changes to UIPanel alpha do not affect alpha of UIInput caret/selection
Post by: wizardsmoke on February 18, 2014, 02:22:51 PM
I added a hack workaround to UIInput.Update(), but it would be nice if this were fixed in an NGUI update.  Pretty please  :D.  Here's my workaround:

  1. void Update ()
  2.         {
  3. #if UNITY_EDITOR
  4.                 if (!Application.isPlaying) return;
  5. #endif
  6.                 if (isSelected)
  7.                 {
  8.                         if (mDoInit) Init();
  9.  
  10.                         if (selectOnTab != null && Input.GetKeyDown(KeyCode.Tab))
  11.                         {
  12.                                 UICamera.selectedObject = selectOnTab;
  13.                                 return;
  14.                         }
  15.  
  16.                         // Process input ignoring non-printable characters as they are not consistent.
  17.                         // Windows has them, OSX may not. They get handled inside OnGUI() instead.
  18.                         string s = Input.inputString;
  19.                        
  20.                         if (!string.IsNullOrEmpty(s))
  21.                         {
  22.                                 for (int i = 0; i < s.Length; ++i)
  23.                                 {
  24.                                         char ch = s[i];
  25.                                         if (ch >= ' ') Insert(ch.ToString());
  26.                                 }
  27.                         }
  28.  
  29.                         // Append IME composition
  30.             if (mLastIME != Input.compositionString)
  31.             {
  32.                 mLastIME = Input.compositionString;
  33.                 UpdateLabel();
  34.                 ExecuteOnChange();
  35.             }
  36.             ///WORKAROUND////////
  37.             else
  38.             {
  39.                 bool caretEnabled = false;
  40.                 float nextBlink = mNextBlink;
  41.  
  42.                 if (mCaret != null)
  43.                 {
  44.                     caretEnabled = mCaret.enabled;
  45.                 }
  46.  
  47.                 UpdateLabel();
  48.  
  49.                 mNextBlink = nextBlink;
  50.  
  51.                 if (mCaret != null)
  52.                 {
  53.                     mCaret.enabled = caretEnabled;
  54.                 }
  55.             }
  56.             ///END WORKAROUND/////
  57.  
  58.                         // Blink the caret
  59.                         if (mCaret != null && mNextBlink < RealTime.time)
  60.                         {
  61.                                 mNextBlink = RealTime.time + 0.5f;
  62.                                 mCaret.enabled = !mCaret.enabled;
  63.                         }
  64.                 }
  65.         }
  66.  
Title: Re: Changes to UIPanel alpha do not affect alpha of UIInput caret/selection
Post by: ArenMook on February 19, 2014, 12:09:15 PM
The panel alpha not propagating is one of the fixes in 3.5.0.
Title: Re: Changes to UIPanel alpha do not affect alpha of UIInput caret/selection
Post by: wizardsmoke on February 19, 2014, 05:06:29 PM
Oh ok, thanks!
Title: Re: Changes to UIPanel alpha do not affect alpha of UIInput caret/selection
Post by: wizardsmoke on March 06, 2014, 04:15:08 PM
After updating to the latest version of NGUI, the problem persists.
Title: Re: Changes to UIPanel alpha do not affect alpha of UIInput caret/selection
Post by: ArenMook on March 07, 2014, 07:56:25 AM
Hmm... I'll look into this.

Edit: Found the issue. I fixed it in the Pro repository, so you will see it live in the next update.