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 小时前
Frida Hook Cocos2dx lua 3.15 的 lua 脚本
lua·cocos2d
智海深蓝2 小时前
海上平行战场:态势模拟三维可视化平台
3d·ue5
众乐乐_20083 小时前
用claude Fabel5一句话生成的游戏:三国天命(有资源包)
游戏
德迅--文琪6 小时前
守护数字游戏乐园:解析DDoS攻击与德迅云安全游戏盾防护方案
游戏·ddos
IT策士6 小时前
Redis 从入门到精通:事务与 Lua 脚本
redis·junit·lua
慧都小妮子6 小时前
不想频繁改 PLC?用 DeviceXPlorer Lua 脚本把产线业务逻辑放到 OPC Server 层
java·junit·lua·takebishi·dxpserver·设备数据采集软件·opc server
jushi899911 小时前
FB Neo 街机模拟器全游戏整合版 含25000+街机游戏怀旧复古街机游戏 解压即玩 热门怀旧街机游戏全集安卓+PC电脑版
android·游戏·电脑
串流游戏联盟12 小时前
UU远程云电脑助力手机畅玩 Steam 新作 SpaceCraft!
游戏
Swift社区13 小时前
AI + 鸿蒙游戏:下一代游戏架构正在形成吗?
人工智能·游戏·harmonyos
利来利往1 天前
Lua 中 or 规则
lua