Files
PythonInUnreal/Plugins/DemoPlugin/use_plugin.py
T
2026-10-27 19:57:03 +01:00

20 lines
508 B
Python
Executable File

from pathlib import Path
import unreal
RENDER_TARGET_ASSET = "/Game/NewTextureRenderTarget2D"
OUTPUT_FILE = Path(unreal.Paths.project_saved_dir()) / "demo_from_cpp.png"
render_target = unreal.load_asset(RENDER_TARGET_ASSET)
# Parametry Out funkcji UFUNCTION wracaja w Pythonie jako tuple.
png_bytes, error = unreal.DemoRenderBridge.render_target_to_png(
render_target
)
if error:
raise RuntimeError(error)
OUTPUT_FILE.write_bytes(bytes(png_bytes))
unreal.log(f"preview saved as {OUTPUT_FILE}")