PyUnity is a Python implementation of the Unity Engine, written in C++. This is just a fun project and many features have been taken out to make it as

pyunity / pyunity

submited by
Style Pass
2021-06-16 08:30:02

PyUnity is a Python implementation of the Unity Engine, written in C++. This is just a fun project and many features have been taken out to make it as easy as possible to create a scene and run it.

Alternatively, you can clone the repository to build the package from source. Then use setup.py to build. Note that it will install Cython to compile.

Debug information is turned on by default. If you want to turn it off, set the PYUNITY_DEBUG_MODE environment variable to "0". This is the output with debugging:

Finally, to run the scene, call scene.Run(). The window that is created is one of FreeGLUT, GLFW or Pygame. The window is selected on module initialization (see Windows subheading).

To create your own PyUnity script, create a class that inherits from Behaviour. Usually in Unity, you would put the class in its own file, but Python can't do something like that, so put all of your scripts in one file. Then, to add a script, just use AddComponent(). Do not put anything in the __init__ function, instead put it in Start(). The Update() function receives one parameter, dt, which is the same as Time.deltaTime.

The window is provided by one of three providers: GLFW, Pygame and FreeGLUT. When you first import PyUnity, it checks to see if any of the three providers work. The testing order is as above, so Pygame is tested last.

Leave a Comment
Related Posts