- Python 2.7.5 (64 bits) or later. The package does not work with Python 3.
- Unity 2019.3. We recommend installing the latest version of Unity 2019 via the Unity Hub; 2019.3 is the minimum.
- Optional: To run the PySide example, you will need the PySide package.
The easiest way to start using Python for Unity is with the Python Script Editor: You can type Python statements in the bottom window. Click on the Execute button or type Ctrl-Return (Cmd-Return on macOS) to run the selected text. Python print statements.
Windows
- Start to Finish Unity Games and Python Coding Master Unity and Blender: Make 40 Games and Low Poly Art We cover basic programming concepts for people who have never programmed before. This course covers key topics in Python and coding in general, including variables, loops, and classes.
- Run python file PythonFiles/server.py using command python server.py on a command prompt. You should start seeing messages being logged inside Unity and the command prompt. Specifically, Unity will send request with a message Hello 10 times, and Python will simply reply World 10 times. There is a one second sleep between each reply on the.
You must use Windows 10, patched to build 1803 or later.
Install the software listed above in the default locations.
When installing Python, make sure to check the option to add to the path is on.
To get PySide after installing Python, open a command terminal and run:
Mac
Install the Unity Hub and Unity in the default location.
System Python
Python for Unity will use the system Python packaged by Apple within the Unity process.
Python with PySide
For the out-of-process API with PySide, installation is more complicated because PySide support is lacking. There are a few workarounds.
The key goal:
- Within Unity, go to
Edit -> Project Settings -> Python
and set theOut of process Python
to point to a Python that includes PySide support. - Verify installation by running the PySide example.
We tested three options to install PySide in a form usable from Unity.
MacPorts
- Install MacPorts
- Install Python and PySide by pasting in the Terminal:
sudo port install python27 py27-pyside
- Within Unity, go to
Edit -> Project Settings -> Python
and set the out of process Python setting to read/opt/local/bin/python2.7
- Restart Unity.
Using Python from Autodesk® Shotgun®
Call R In Python
- Install the Autodesk® Shotgun® Desktop app
- Within Unity, go to
Edit -> Project Settings -> Python
and set the out of process Python setting to read/Applications/Shotgun.app/Contents/Resources/Python/bin/python
- Restart Unity.
Using Python from Autodesk® Maya®
- Install Autodesk® Maya®
- Within Unity, go to
Edit -> Project Settings -> Python
and set the out of process Python setting to read/Applications/Autodesk/maya2019/Maya.app/Contents/bin/mayapy
- Restart Unity.
On CentOS7
Python is part of the distribution and is compatible with the integration.
How To Use Python In Unity
To install PySide paste in a terminal:
Python In Unity
It is also possible to install PySide from pip, but it requires the
qt-devel
package to be installed: