Unreal Engine Python [Visual Studio Code - Extension]

Hi,

I’ve been working on an extension for Visual Studio Code to assist when writing Python code for Unreal Engine.

The extension can be found here:


Features:

Execute Code

Run code in Unreal Engine directly from within VS Code:

Command: Unreal Python: Execute
Keyboard Shortcut: Ctrl + Enter

The selected text will be executed, or if nothing is selected the entire document will be executed.


Setup Code Completion

Setup code completion for the unreal module based on the current project.


Command: Unreal Python: Setup code completion


Debugging

Attach VS Code to Unreal Engine to debug your scripts, set breakpoints and step through the code.

Command: Unreal Python: Attach


+ there are a few more features planned for the future :smiley:




If you were to start using this extension and run into any issues or have any questions, do let me know!

And if anyone would be interested, the source code for this extension can be found on GitHub:

5 Likes

With the latest version it’s now also possible to browse the UE Python documentation within VS Code. This documentation is generated on the fly based on the currently opened Unreal Engine instance, therefore it will always be up to date & include any custom C++ functions/classes that you have exposed to Blueprints/Python.

The documentation tab can be opened using the VS Code command: Unreal Python: Open Documentation

documentation-demo

Hello, I got the following warning after typing Unreal Python: Attach, and then another warning after I clicked “Install”. Did I miss any necessary Settings?
@_$8NTQOWBH}{N@NVR{X{$W
U5K4{LDN835EU8A}MHXK)YM

Hi,

Hmm, not sure why it would fail, I’ll try to do some testing to see if I can repro it.
I should probably also add some more info as to why the installation failed, will look into that.

  • What version of Unreal Engine are you running?
  • Which OS are you using?

For now though, you can install debugpy manually:

Open up cmd and run the following command (Make sure the path pointing to the python interpreter where your engine is installed.)
"C:\Program Files\Epic Games\UE_<VERSION>\Engine\Binaries\ThirdParty\Python3\Win64\python.exe" -m pip install debugpy

This is the command that VS Code will run when you press Install. So if it gives you any errors, please let me know what it says.

Cheers,
Nils

Hi
Thanks for your reply, I solved the problem by repeated installation shortly after I asked.

Maybe I missed some settings, I’m still a novice so I don’t know what’s going on,.

I’m using UE5.3 and Win11, now the plugin works fine. If the same problem occurs next time,I will try the method you provided. thank you for your sharing.

In addition, I want to ask a question. There are very few tutorials for UE&python, and the API documentation provided by UE is very simple and crude, which is difficult for me to learn. If you know of a learning path for this, can you share it with me?

Of course, this question may be a bit presumptuous or inexplicable, but anyway, I’ll keep learning.

thanks again for everything you share, great work!

Cheers
Witcher

Huh, weird that it worked the second time. Anyway thanks for the info, I’ll be sure to run some tests on UE5.3!

Personally I always find it easiest to first come up with an idea of a tool/script that I want to create, then once I have that I start from there and google one thing at a time.
There’s also the TechArt slack channel, which is always a good place to ask questions: Tech-Artists.Org is now on Slack! - Community - Tech-Artists.Org

Thank you for your generosity of sharing, I didn’t expect much from this question, and now it seems that I got a very high quality answer.

And I haven’t noticed your homepage before. It turns out that you participated in the production of It Takes Two.I didn’t expect such an excellent production staff to talk to me.

This is a very well-known game. I haven’t bought it because of my busy work. Now, I decided to experience it.

Looking forward to your next masterpiece.

Cheers
Witcher

1 Like

Haha, thanks and hope you enjoy the game! :smiley:

Pushed a new update to the extension yesterday, any errors that occurs during the installation of debugpy will now be logged & shown to the user.
So if this happens again there should be more information to go on, thank you for reporting this issue!

You should add to your documentation that “Enable Remote Execution?” should be set to ‘True’ in UnrealEd editor settings (“Python remote execution” section), otherwise the connection cannot be established!

Hi,

As of right now if Remote Execution isn’t enabled and the user tries to e.g. execute code, they will be presented with a message including a “Help” button that takes the user to a page showing how to enable it: Failed to connect to Unreal Engine [Troubleshooting] · nils-soderman/vscode-unreal-python Wiki · GitHub

But adding this link to the ReadMe might not be a bad idea!