- 最后登录
- 2017-6-23
- 注册时间
- 2012-2-18
- 阅读权限
- 90
- 积分
- 33060
- 纳金币
- 32449
- 精华
- 23
|
具体实现方法如下:
其实很简单只需要GUI使用中文字体就行了,不好意思忙了一周白忙了心里郁闷中
代码如下自己测试(字体到win下字体中找小于9m的中文字体即可);
以下内容需要回复才能看到
using UnityEngine;
using System.Collections;
public class test : MonoBehaviour {
// Use this for initialization
public GUISkin gskin;
private string inputStr="";
private Vector2 scrollPosition;
private string result=""; //结果
void Start () {
inputStr="直接输入中文";
}
// update is called once per frame
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(new Rect(200,50,200,100));
scrollPosition = GUILayout.BeginScrollView (scrollPosition);
string[] list=result.Split('*');
foreach (string entry in list)
{
GUILayout.BeginHorizontal();
GUILayout.Label(entry);
GUILayout.FlexibleSpace ();
GUILayout.EndHorizontal();
}
GUILayout.EndScrollView ();
GUILayout.EndArea();
if(Event.current.type == EventType.keyDown && Event.current.character == '
' && inputStr.Length > 0)
{
result+=inputStr+"*";
inputStr = "";
scrollPosition.y = 1000000;
}
}
}回复
|
|