代碼如下:自測(從win下的字體中找壹個小於9m的中文字體);
使用UnityEngine
使用系統。收藏;
公共類測試:MonoBehaviour {
//使用它進行初始化
公共GUISkin gskin
私有字符串inputStr =
私有向量scrollPosition
私有字符串結果= " ";//結果
void Start () {
InputStr= "直接輸入中文";
}
//每幀調用壹次update
void update () {
}
void OnGUI()
{
GUI.skin = gskin
inputStr=GUI。TextField(new Rect(200,154,200,30),inputStr,25);
GUI。Box(new Rect(200,50,200,100)," ");
GUILayout。BeginArea(新Rect(200,50,200,100));
scrollPosition = GUILayout。beginsicollview(scroll position);
string[]list =結果。拆分(' * ');
foreach(列表中的字符串條目)
{
GUILayout。beginholizontal();
GUILayout。標簽(條目);
GUILayout。flexible space();
GUILayout。end horizontal();
}
GUILayout。EndScrollView();
GUILayout。EndArea();
if(event . current . type = = event type . keydown & amp;& ampEvent.current.character == '
& amp#39;& amp& ampinputStr。長度& gt0)
{
result+= input str+" * ";
inputStr =
scroll position . y = 1000000;
}
}
}