0

I have some code that is running in the python console reading out text lines.

Is it possible to feed the output of the python console to my Unity3D game script so that it can trigger some actions in my game?

in other words: python console running in the background outputs commands that need to feed to my Unity game.

2
  • What Python console? Did you embed Python in your app? If not, did you mean the regular command prompt / Terminal app? Or a command window that you launch from within your app but is an external process? Commented Nov 19, 2014 at 0:17
  • I did not embed python in my app. This is just the windows terminal output that i would like to feed to unity. This is external of the game Commented Nov 19, 2014 at 0:25

2 Answers 2

1

An efficient solution would be to use TCP sockets in both the Python script and the Unity-side script. Since the Python-side is serving the data, then designate it as the server socket and make the socket on the Unity-side the client. This solution will be much faster than writing and reading to a shared file.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, this is exact path I was on.
0

If you're on windows you can use Process, spin up python and read standard out and collect the output. Out side of that, if the process isn't started in Unity, you best bet is probably to monitor a file in a particular directory for changes and read in those changes which would have been the output from your python console.

Here is an example of UnityScript creating and executing a process.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.