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的

相关推荐
Zhichao_974 小时前
【UE5.3 C++】ARPG游戏 02-创建Pawn(以乌鸦为例)
游戏·ue5
AI视觉网奇5 小时前
nvidia 插件安装使用笔记
笔记·ue5
小鹏linux8 小时前
经典怀旧类小游戏:像素贪吃蛇【含完整源码和部署文档】
游戏
分***89 小时前
MAME街机模拟器下载 支持全街机游戏 多系统适配 中文设置教程
游戏·mame街机模拟器·拳皇模拟器·三国战记模拟器·合金弹头模拟器
[苦行僧]9 小时前
ue Gameplay Message Subsystem plugin
ue5
会员源码网11 小时前
游戏行业专属支付通道搭建 – 聚合支付系统支持当面付与三方支付
游戏·源代码管理
呆呆敲代码的小Y11 小时前
【Unity 实用工具篇】| UX Tool 工具 快速上手使用,提高日常开发效率
游戏·unity·游戏引擎·游戏程序·ux
fredricen11 小时前
Openwrt21.02实现文件列表展示并下载文件
lua·openwrt
skywalk81631 天前
wow文件处理trinitycore的文件处理
开发语言·游戏
youngee111 天前
hot100-64跳跃游戏
算法·游戏