Bootstrap Chameleon Logo

Split unreal.py for a better development experience

Code highlighting and auto-completion in PyCharm and VSCode provide development more efficiency when we develop python editor tools using this way.

However, the unreal-generated stub file unreal.py becomes larger in every newer unreal engine. In Unreal 5.1, unreal.py is over 21MB (and its size increases with the number of plug-ins you enable), which causes PyCharm gives a hint of low memory and become much slower.

Test Cases for TAPython

Changing the memory settings can improve it, but browsing the class and function definitions in a python file over 400,000 lines is not a good experience.

My way is to split the unreal.py file into several smaller files by class name and then find the required API information in separate files.

Split

I uploaded the python tool for sharding unreal.py to the GitHub repository. You can find it here.

It does the following two steps.

  1. Copy unreal.py from Intermediate/PythonStub in your project to TA/TAPython/Python directory
  2. Split unreal.py with the class names and put the files in the TA/TAPython/Python/unreal directory.

After that, I used them instead of the unreal.py was a great experience.

G_019_goto_definition

Additional benefits:

  • The file size tells you which classes are UE's most essential objects. T065_filesize_of_classes
  • Quickly find special classes, such as editor libraries and subsystems, which is important for python editor programming.
  • It is convenient to compare the stubs to find what has been modified in different versions of Unreal Engine. G_019_stubs_compare

~~### The remaining issues~~

~~We still need to keep the unreal.py file. And it seems like we can't only use the generated unreal directory for auto-completion, although it has the same content. If you know how to get it work, please share it.~~

Update on 2023 3rd May, Autocompletion for python. Python, JSON, and ChameleonData can all be auto-completed.