Bug1:全角文字を入力し、キャレットを真ん中に移動し、全角を入力すると、キャレットの位置から文字列の最後までが選択されてしまう、そして、入力された新し文字が一番後ろになっている。
1)まずは string ime = ""; を定義する
2)void Update ()にある string ime = Input.compositionString; を ime = Input.compositionString;に変更する。
2)void Update ()にある
mSelectionEnd = string.IsNullOrEmpty(ime) ? mSelectionStart : mValue.Length + ime.Length;
を下記のように変更する:
mSelectionEnd = string.IsNullOrEmpty(ime) ? mSelectionStart : mSelectionStart;
3)void UpdateLabel ()にある
int end = mSelectionEnd - mDrawStart;
を下記のように変更する:
int end = mSelectionEnd + ime.Length - mDrawStart;
以上です。
Bug2:全角を入力したあとに、確定してない状態で、マウスを画面上にタッチすると、文字が複製されて、二回表示されている。
Updateメソッドにある // Windows has them, OSX may not. They get handled inside OnGUI() instead. の下に下記のソースを追加する
if (Input.GetMouseButton(0) || Input.GetMouseButton(1) || Input.GetMouseButton(2))
mSelectionStart = mSelectionEnd = mLastInputPos;
s = mLastIME;
if UNITY_STANDALONE
protected int mLastInputPos = 0;
endif
を上に定義する。
protected virtual void OnPress (bool isPressed)
に下記のソースを追加する
if UNITY_STANDALONE
mLastInputPos = mSelectionEnd;
endif
update() 中修改如下
if ((ime.Length == 1 || string.IsNullOrEmpty(ime)) && !string.IsNullOrEmpty(Input.inputString))
GetLeftText()中修改如下
int min = (mValue.Length <= Mathf.Min(mSelectionStart, mSelectionEnd)) ? mValue.Length : Mathf.Min(mSelectionStart, mSelectionEnd);
return (string.IsNullOrEmpty(mValue) || min < 0) ? "" : mValue.Substring(0, min);
UpdateLabel()中修改如下
int end = mSelectionEnd - mDrawStart; 修改成 int end = mSelectionEnd + ime.Length - mDrawStart;