Current location - Trademark Inquiry Complete Network - Futures platform - How to make Unity3D support Chinese input and output?
How to make Unity3D support Chinese input and output?
It's actually quite simple. Just use Chinese fonts in GUI. I'm sorry for being busy for a week and feeling depressed.

The code is as follows: self-test (find a Chinese font less than 9m from the fonts under win);

Using UnityEngine

Use the system. Collection;

Public class test: MonoBehaviour {

//Use it for initialization.

Public GUISkin gskin

Private string inputStr =

Private vector scrollPosition

Private string result = ""; //result

void Start () {

InputStr= "Input Chinese directly";

}

//Call update once every 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。 beginsicollview(scroll position);

String[]list = result. Split ('*');

Foreach (string entry in list)

{

GUILayout。 beginholizontal();

GUILayout。 Label (entry);

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。 Length & gt0)

{

result+= input str+" * ";

inputStr =

scroll position . y = 1000000;

}

}

}