0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Unity3D:NGUI BUG

0
Last updated at Posted at 2017-02-07

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;

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?