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的

相关推荐
chengpei1471 小时前
Moonlight + Sunshine互联网串流方案介绍
游戏
向宇it2 小时前
2025年技术总结 | 在Unity游戏开发路上的持续探索与沉淀
游戏·unity·c#·游戏引擎
数说故事3 小时前
有哪些采集游戏大数据的工具推荐?数说聚合提供全网游戏阵地数据
游戏·数据采集·用户洞察
AI视觉网奇7 小时前
Audio2Face 实时推理
笔记·ue5
科技块儿7 小时前
如何快速识别游戏安全运营中外挂与多开用户?
安全·游戏
前端小L7 小时前
贪心算法专题(五):覆盖范围的艺术——「跳跃游戏」
数据结构·算法·游戏·贪心算法
前端小L7 小时前
贪心算法专题(六):步步为营的极速狂飙——「跳跃游戏 II」
算法·游戏·贪心算法
HMS Core7 小时前
《地铁跑酷》接入HarmonyOS SDK,显著优化游戏启动体验
游戏·华为·harmonyos
u9king7 小时前
虚幻引擎UE5.6编译卡在rc2.exe长时间未响应的解决方法
visualstudio·ue5·虚幻·ue5.6·rc2.exe
烧冻鸡翅QAQ1 天前
从0开始的游戏编程——开发前的编程语言准备(JAVAScript)
开发语言·javascript·游戏