Unreal PythonScriptPlugin

Unreal PythonScriptPlugin

文章目录

示例代码,引擎里有很多插件已经用 py 写编辑器脚本了

复制代码
unreal.get_editor_subsystem(unreal.LevelEditorSubsystem).load_level("/Game/maps/UVlayoutTest.UVlayoutTest")
unreal.get_editor_subsystem(unreal.StaticMeshEditorSubsystem).join_static_mesh_actors(list_of_actors, my_options)
unreal.get_editor_subsystem(unreal.StaticMeshEditorSubsystem).join_static_mesh_actors(join_options=my_options, actors_to_join=list_of_actors)

Python vs UnLua

UnLua 的主要缺陷在于缺乏类型和强大的 IDE

  • TArray<T> 没法提示
  • IDE 缺乏重构
  • 在 Lua 无法进行 OOP
  • 无法在 Lua 定义 UClass,UProperty

写小范围的脚本还可以,但是。。

官方文档

https://docs.unrealengine.com/en-US/Engine/Editor/ScriptingAndAutomation/Python/index.html

  • init_unreal.py,初始化脚本,可以额外配置
  • Python 路径,默认如下,可以额外配置
  • Python API
    • 支持 UE 反射得到的 蓝图 API
    • Python 类型和 UE 类型映射,支持 isinstance 和 type
    • Stub 提示文件,Engine\Plugins\Experimental\PythonScriptPlugin\SphinxDocs
    • 编辑器相关
      • Undo/Redo
      • 慢任务进度条

Python 路径

复制代码
项目文件夹中的 Content/Python 子文件 夹。

主虚幻引擎安装中的 Content/Python 子文件 夹。

每个启用的插件文件夹中的 Content/Python 子文件 夹。

用户目录中的Documents /UnrealEngine/Python文件夹。
例如,在 Windows 10 上,这相当于C:/Users/Username/Documents/UnrealEngine/Python

PyStub

=> unreal.py

类型很关键,这个包含 Engine 和 Game 所有蓝图反射 API,类似 UnLua Intellisense

入口函数

复制代码
FPyWrapperTypeRegistry::GenerateStubCodeForWrappedTypes

DoString

入口函数

复制代码
FUnrealEnginePythonModule::RunString

执行没什么,就是准备了 unreal 的环境注入 unreal API

TODO 看眼反射怎么export到python的

相关推荐
七仔啊2 小时前
UE5源码下载及编译
ue5
Zhichao_976 小时前
【UE5.8 MCP】接入AI大模型
ue5
hflmwl86 小时前
Wise Game Booster 游戏加速软件
游戏·wisegamebooster·游戏加速软件
Solange__9 小时前
工业产线怎么用AI生成3D场景?从现场采集、部件重建到数字孪生交付的完整方案
人工智能·游戏·3d·ai·语言模型·自然语言处理·关卡设计
一次旅行9 小时前
2026.10.13 AI产业深度解读|硬件互联标准更新;Agent工程启示;开源社区AI政策转向;游戏与科研AI双线突破
人工智能·游戏·开源
xiaolang_8616_wjl11 小时前
预告_c++游戏
游戏
乌萨达12 小时前
绿梦时空之声pc怎么玩?预下载、模拟器安装与键鼠设置指南
游戏·安卓模拟器·雷电模拟器
RoboWizard13 小时前
固态硬盘的读写速度多少才够游戏用?
游戏
笨鸟先飞的橘猫13 小时前
C 扩展开发指南:从 Lua 到 skynet 的完整链路
c语言·lua
棉猴1 天前
玩游戏学Python9-算术运算符应用1
python·游戏·pygame·玩游戏·游戏编程