###前提・実現したいこと
UnityのInputFieldを使って、日本語入力の全角変換中に確定させない状態でInputFieldからフォーカスを外すと変換中の文字が倍加するバグがあり、倍加させない方法を探しております。
###補足情報(言語/FW/ツール等のバージョンなど)
Unity 5.6.0f3
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
回答1件
0
InputFieldに張り付けて使ってください
#if UNITY_EDITOR || UNITY_EDITOR_WIN
using UnityEngine;
using UnityEngine.UI;
public class textzenkaku : MonoBehaviour {
InputField T1;
string S ="";
int pos = 0;
int Tpos = 0;
// Use this for initialization
void Start () {
T1 = gameObject.GetComponent<InputField>();
} // Update is called once per frame void Update () { if (Input.GetMouseButtonDown(0)) { if (T1.text != "") { if (S != T1.text) { if (S == "") { if (T1.text.Length > 1 && T1.text.Length % 2 == 0) { int cun = T1.text.Length; if (T1.text.Substring(0, cun / 2) == T1.text.Substring(cun / 2, cun / 2)) { T1.text = T1.text.Substring(0, cun / 2); } } } else { if (T1.text.Length - Tpos > 1) { if (Tpos + (pos - Tpos) * 2 == T1.text.Length) { string hantei = T1.text.Substring(Tpos); if (hantei.Length > 1 && hantei.Length % 2 == 0) { int cun = hantei.Length; if (hantei.Substring(0, cun / 2) == hantei.Substring(cun / 2, cun / 2)) { T1.text = T1.text.Substring(0, Tpos) + hantei.Substring(0, cun / 2); } } } else { Debug.Log((T1.text.Length - (Tpos + (pos - Tpos) * 2))/2); int usiro = (T1.text.Length - (Tpos + (pos - Tpos) * 2)) / 2; int mae = Tpos - usiro; string hantei = T1.text.Remove(T1.text.Length - usiro).Substring(mae); if (hantei.Length > 1 && hantei.Length % 2 == 0) { int cun = hantei.Length; if (hantei.Substring(0, cun / 2) == hantei.Substring(cun / 2, cun / 2)) { T1.text = T1.text.Substring(0, mae) + hantei.Substring(0, cun / 2) + T1.text.Substring(T1.text.Length-usiro, usiro); } } } } } } } } S = T1.text; Tpos = T1.text.Length; pos = T1.selectionAnchorPosition; }
}
#endif
投稿2018/06/06 07:33
総合スコア8
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。