LoginSignup
0
0

More than 5 years have passed since last update.

macOSでも日本が入力できるInputField

Last updated at Posted at 2018-08-19

時間ができたらまともにかく

標準のInputFieldはどうやっても無理です。ハンドラで小細工してももっと下のところに問題あるので無理。無理。

TextMesh Pro の InputField が下回りを自作してて、それを使うと大丈夫。
ただし、Calet周りのエラーハンドリングに漏れがあり、IME仮確定状態におけるスコープで強制的に空のtextを参照してしまう場合に例外を吐く箇所がある。

一応、一番目立つところだけ対処すれば、ある程度は実用的。
(見つけるたびに例外ハンドリング追加してく...)

'/Users/User名/Library/Unity/cache/packages/packages.unity.com/com.unity.textmeshpro@1.2.4/Scripts/Runtime/TMP_InputField.cs'

の2330行目あたりを

try {
  if (caretPositionInternal > 0)
  {
      m_Text = text.Remove(GetStringIndexFromCaretPosition(caretPositionInternal - 1), 1);
      caretSelectPositionInternal = caretPositionInternal = caretPositionInternal - 1;
      stringSelectPositionInternal = stringPositionInternal = GetStringIndexFromCaretPosition(caretPositionInternal);
  }
  m_isLastKeyBackspace = true;
  SendOnValueChangedAndUpdateLabel();
}
catch(System.ArgumentOutOfRangeException e){
  Debug.Log(e.Message);
}

問題は、Packmanagerで入れてる場合、アップデートのたびにこれをしなくてはいけない(許容範囲)

そして、CloudBuildとかでビルドするときに、これの適用が外れるというところで、どうしたもんかい。。。

追記 : 例外対応

無を参照する系で、TMP_InuptField.csの2934行目付近でもなんかよく起きる。
適当にチェックを追加。

            int currentLineIndex = 0;
            int nextLineStartIdx = 0;

            if((textInfo.characterInfo != null) && (textInfo.characterInfo.Length > startChar)){
                currentLineIndex = textInfo.characterInfo[startChar].lineNumber;
            }
            if((textInfo.lineInfo != null) && (textInfo.lineInfo.Length > currentLineIndex)){
                nextLineStartIdx = textInfo.lineInfo[currentLineIndex].lastCharacterIndex;
            }
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