Properties¶
How do I expose a value to Unreal?
Only fields declared with ue.uproperty(...) are Unreal properties. Ordinary annotations stay Python-only.
@ue.uclass
class Beacon(ue.Actor):
strength: int = ue.uproperty(3)
target: ue.Actor | None = ue.uproperty(None)
tags: list[str] = ue.uproperty(default_factory=list, category="Debug")
label: str = "Python-only"
Options¶
| Option | Meaning |
|---|---|
| first argument | The default value. |
default_factory |
A callable producing the default (use for lists, dicts, structs). |
readonly |
Not editable in the editor or Blueprints. |
transient |
Not saved. |
replicated |
The server's value is sent to clients. See Replicated properties. |
rep_notify |
Name of a method called on clients when a new value arrives (implies replicated). |
category |
Editor category. |
meta |
Extra metadata as a dict[str, str]. |
Notes¶
- The annotation gives the Unreal type. Fields must be public instance annotations.
ue.uproperty()on an inherited property name is an error: the property already exists. Assign a value in the class body to set its default instead.- A struct value you read is a copy: read it, modify it, assign it back.
score = self.score
score.coins += 1
self.score = score