Use Python from Blueprints¶
How do Blueprint users get at my Python classes?
Python classes are real Unreal classes, so Blueprints use them without any glue.
| Python | In Blueprints |
|---|---|
@ue.uclass |
Use the Python class as a Blueprint parent (unless blueprintable=False). Actors can also be placed in a level. |
ue.uproperty(...) |
A variable you can read, write and edit in the Details panel. |
@ue.ufunction |
A callable node. pure=True gives a node without execution pins. |
@ue.udelegate |
An event dispatcher: Bind Event and Call. |
@ue.uenum, @ue.ustruct |
Enum and struct types for variables and pins. |
@ue.uclass on ue.Interface |
An interface Blueprints can implement and message. |
@ue.uclass
class Door(ue.Actor):
is_open: bool = ue.uproperty(False, category="Door")
@ue.udelegate
def on_opened(self, by: ue.Actor | None) -> None: ...
@ue.ufunction
def open(self, by: ue.Actor | None) -> None:
self.is_open = True
self.on_opened.broadcast(by)
Create a Blueprint that inherits from Python¶
-
In the Content Browser's Python Classes folder, right-click your Python class and choose Create Blueprint class based on that class.
-
Name the new Blueprint, choose its Content folder, and create it. Set initial values in Class Defaults, add components, or call Python functions in the Event Graph.
-
Click Compile and Save. If the Blueprint is an actor, drag it into the level to try it.
You can also choose Add → Blueprint Class and find your Python class under All Classes. If Python Classes is hidden, enable it in Content Browser Settings.
Keep source for classes used by saved levels or Blueprints under Python/scripts/, or register it in UnrealPy project settings, so UnrealPy can find the class every time the project opens.
Changing a type later¶
Redefined structs and enums update loaded Blueprint variable types and graph references; Blueprints are recompiled and existing variable values are restored by name. Save the affected assets to persist the update.
Only reflected members cross the boundary. Ordinary Python attributes are not visible to Blueprints.
