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的

相关推荐
huoyueyi5 小时前
《融天AI-APP从0到1开发实录》
开发语言·lua
凯基迪科技11 小时前
Unity游戏加密锁逆向方案、选型与攻防分析
游戏·unity·游戏引擎
Solange__12 小时前
航天科普怎么用AI生成3D场景?从科学约束、尺度分层到网页展示的完整方案
图像处理·人工智能·游戏·3d·ai·自然语言处理·关卡设计
努力努力再努力wz19 小时前
【Lua入门系列】从动态类型到变量作用域:彻底理解 local、全局变量与跨文件访问
开发语言·junit·lua
C MIKE19 小时前
小熊杂货铺小游戏开发
游戏
装备研究社1 天前
对峙2掉线排查实测
游戏
xcLeigh1 天前
Unity基础:Destroy与DestroyImmediate——正确销毁游戏物体的方式
游戏·unity·游戏引擎·教程
sunxfancy1 天前
EVEngine 0.6 到 0.6.1:让 AI 参与游戏开发,还需要补上哪些环节?
游戏
sunxfancy1 天前
AI 改完场景,怎么知道没改坏?EVEngine 0.6.1 的白盒自动试玩
游戏
风无雨2 天前
三角洲如何快速拾取物品
游戏