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的

相关推荐
Nicole Potter5 小时前
内存泄漏出现的时机和原因,如何避免?
c++·游戏·面试·c#
Maya动画技术10 小时前
ue5.5崩溃报gpu错误快速修复注册表命令方法
ue5·ue5.5崩溃报gpu错误
alenliu062114 小时前
跟着 Lua 5.1 官方参考文档学习 Lua (12)
lua
夜晚中的人海1 天前
【C语言】------ 实现扫雷游戏
android·c语言·游戏
勘察加熊人1 天前
fastapi房产销售系统
数据库·lua·fastapi
交换机路由器测试之路1 天前
【资料分享】wireshark解析脚本omci.lua文件20250306版本发布(独家分享)
网络协议·测试工具·wireshark·lua·omci
q567315231 天前
使用Lua和lua-resty-http-simple库的爬虫程序爬取图片
爬虫·http·lua
AnalogElectronic1 天前
整理一下高级设施农业栽培学这门课程的所有知识点
学习·lua
轻口味2 天前
【每日学点HarmonyOS Next知识】截图组件截取列表、Toggle组件、Web组件请求头、列表选择弹窗、游戏加速
前端·游戏·harmonyos·harmonyosnext
总斯霖2 天前
P8255 [NOI Online 2022 入门组] 数学游戏 题解
c++·算法·游戏