unreal-pcg-python
Guide for Unreal Engine 5.x PCG (Procedural Content Generation) Python integration. Covers the PCGPythonInterop plugin, the Execute Python Script node, PCG Python API (PCGComponent, PCGBlueprintElement, PCGSpatialData, PCGPointData), editor automation, custom PCG nodes via Python, and known limitations. Use when the user asks about PCG Python, PCGPythonInterop, Execute Python Script node, Python scripting for procedural generation, automating PCG graphs with Python, or creating custom PCG nodes with Python/Blueprint.
maystudios · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add maystudios/claude-skills --skill unreal-pcg-python技能说明
name: unreal-pcg-python description: > Guide for Unreal Engine 5.x PCG (Procedural Content Generation) Python integration. Covers the PCGPythonInterop plugin, the Execute Python Script node, PCG Python API (PCGComponent, PCGBlueprintElement, PCGSpatialData, PCGPointData), editor automation, custom PCG nodes via Python, and known limitations. Use when the user asks about PCG Python, PCGPythonInterop, Execute Python Script node, Python scripting for procedural generation, automating PCG graphs with Python, or creating custom PCG nodes with Python/Blueprint.
Unreal Engine PCG Python Integration Guide
Overview
Python interacts with UE5's Procedural Content Generation (PCG) framework at two levels:
- PCGPythonInterop Plugin (UE 5.5+, Beta) -- An editor-only PCG graph node ("Execute Python Script") that runs Python code mid-graph.
- PCG Python API (UE 5.2+) -- Standard
unrealmodule classes (PCGComponent,PCGBlueprintElement, etc.) for editor automation and custom node logic.
Important: All PCG Python functionality is editor-only. Python cannot run in packaged builds or at game runtime.
Official Documentation
Community Resources
| Resource | URL |
|---|---|
| Forum: Create PCG Graph with Python | https://forums.unrealengine.com/t/create-pcg-graph-with-python/1714891 |
| Forum: Generate PCG through Python | https://forums.unrealengine.com/t/generate-pcg-through-python-script/2053107 |
| Forum: Change PCG Parameters from Python | https://forums.unrealengine.com/t/how-to-change-pcg-graph-parameters-from-python/2060532 |
| Custom PCG Nodes Guide (Blueshift) | https://blueshift-interactive.com/2025/09/03/how-to-create-custom-pcg-nodes/ |
| PCG Extended Toolkit (community C++ plugin) | https://github.com/PCGEx/PCGExtendedToolkit |
| Houdini to PCG Data Example | https://github.com/cgtoolbox/HoudiniToPCGDataExample |
1. PCGPythonInterop Plugin ("Execute Python Script" Node)
Plugin Details
- Location:
Engine/Plugins/PCGInterops/PCGPythonInterop/ - Status: Beta (
IsBetaVersion: true,EnabledByDefault: false) - Module:
PCGPythonInteropEditor(Editor-only) - Dependencies:
PCGplugin +PythonScriptPlugin
Enabling the Plugin
- Enable Python Editor Script Plugin (under Plugins > Scripting)
- Enable PCG Python Interop (under Plugins > Procedural Content Generation)
- Restart the editor
The "Execute Python Script" Node
This is the only node the plugin adds. It runs Python code within a PCG graph.
Two input modes:
| Mode | Description |
|---|---|
Input | Reads Python source from an FString attribute on the "Source" pin, or uses an inline default script |
File | Executes a .py file from disk |
Key characteristics:
- Runs on main thread only (Python GIL constraint)
- Not cacheable -- re-executes every time the graph runs
- No data output -- output pin is dependency-only (for execution ordering)
- Shows an editor toast on execution (suppressible via
bMuteEditorToast) - Default inline script:
print("Hello PCG World!")
Settings (UPROPERTY):
ScriptInputMethod -- EPCGPythonScriptInputMethod (Input or File)
ScriptSource -- FPCGAttributePropertyInputSelector (which attribute holds the script)
ScriptPath -- FFilePath (path to .py file, filtered to *.py)
bMuteEditorToast -- bool (suppress editor notification)
All properties marked PCG_Overridable (can be set via PCG parameter overrides).
Planned Future Features (from source TODOs)
EvaluateStatementmode for line-by-line feedback- Parameter inputs/outputs (get/set variables from within Python, like Blueprint/HLSL nodes)
- Generalized source editor in PCG for HLSL + Python
- Potential multi-thread support
2. PCG Python API (Editor Automation)
These classes are available via import unreal in any UE Python script, independent of the PCGPythonInterop plugin.
Create PCG Graph Assets
import unreal
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
graph = asset_tools.create_asset(
'MyPCGGraph', '/Game/PCG',
阅读完整来源 ↗