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的

相关推荐
Liudef066 小时前
儿童趣味记忆配对游戏
css·游戏·css3
crazy_yun10 小时前
通用游戏前端架构设计思考
游戏
向宇it18 小时前
【unity小技巧】在 Unity 中将 2D 精灵添加到 3D 游戏中,并实现阴影投射效果,实现类《八分旅人》《饥荒》等等的2.5D游戏效果
游戏·3d·unity·编辑器·游戏引擎·材质
witton18 小时前
C语言使用Protobuf进行网络通信
c语言·开发语言·游戏·c·模块化·protobuf·protobuf-c
alansoulKing20 小时前
2025年7月:打cs1.5 600元装机台式电脑方案A
游戏·电脑
HMS Core20 小时前
用AI重塑游戏体验:《诛仙2》携手HarmonyOS SDK实现性能与功耗双赢
人工智能·游戏·harmonyos
向宇it21 小时前
Unity Universal Render Pipeline/Lit光照材质介绍
游戏·unity·c#·游戏引擎·材质
困惑阿三21 小时前
Mac mini 高性价比扩容 + Crossover 游戏实测 全流程手册
游戏·macos
不爱说话的采儿1 天前
UE5详细保姆教程(第四章)
笔记·ue5·游戏引擎·课程设计
二DUAN帝1 天前
UE实现路径回放、自动驾驶功能简记
人工智能·websocket·机器学习·ue5·自动驾驶·ue4·cesiumforue