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.
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.¶
- Copy unreal.py from Intermediate/PythonStub in your project to TA/TAPython/Python directory
- 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.
Additional benefits:¶
- The file size tells you which classes are UE's most essential objects.
- 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.
~~### 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.