How to get text into Unity? [closed]
-
06-06-2021 - |
Domanda
I have a basic Java program with output of "hello world". What I want to do is to write a Java script to run that program and import that into Unity so I can use it in my program in Unity.
Is there a way?
Soluzione
You can communicate with Unity from a Java application trough OSC(Open Sound Control) and send text, commands triggers or load an external file(xml or similar) into Unity.
Unity and Open Sound Control http://www.sundh.com/blog/2012/07/unity-processing-demo/
Altri suggerimenti
On unity you have to use function OnGui() to show text. In the related documentation you have many example.
For show message in a console just use in a javascript:
Debug.Log("Hello world");
You can also put files in your /Resources folder in your unity project, then load them at run time. These can be pretty much anything. models, prefabs, materials... could be text files (maybe comma delimited txt files, that you parse) or more typically .xml files that you can easily access and extract data (text) from.
to load any resource file, use resources.load() http://docs.unity3d.com/Documentation/ScriptReference/Resources.Load.html