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?

È stato utile?

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

Don't use OnGui as this is bad for performance rather use Canvas to edit and place the text you prefer on or in (parent) object you want.

to make this look better put the font size higher and the width and height lower. this will make it look sharper.

Located here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top