void Update ()
{
#if UNITY_EDITOR
if (!Application.isPlaying) return;
#endif
if (isSelected)
{
if (mDoInit) Init();
if (selectOnTab != null && Input.GetKeyDown(KeyCode.Tab))
{
UICamera.selectedObject = selectOnTab;
return;
}
// Process input ignoring non-printable characters as they are not consistent.
// Windows has them, OSX may not. They get handled inside OnGUI() instead.
string s = Input.inputString;
if (!string.IsNullOrEmpty(s))
{
for (int i = 0; i < s.Length; ++i)
{
char ch = s[i];
if (ch >= ' ') Insert(ch.ToString());
}
}
// Append IME composition
if (mLastIME != Input.compositionString)
{
mLastIME = Input.compositionString;
UpdateLabel();
ExecuteOnChange();
}
///WORKAROUND////////
else
{
bool caretEnabled = false;
float nextBlink = mNextBlink;
if (mCaret != null)
{
caretEnabled = mCaret.enabled;
}
UpdateLabel();
mNextBlink = nextBlink;
if (mCaret != null)
{
mCaret.enabled = caretEnabled;
}
}
///END WORKAROUND/////
// Blink the caret
if (mCaret != null && mNextBlink < RealTime.time)
{
mNextBlink = RealTime.time + 0.5f;
mCaret.enabled = !mCaret.enabled;
}
}
}