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的

相关推荐
wanhengidc20 小时前
服务器数据管理如何
运维·服务器·网络·游戏·智能手机
彭于晏Yan1 天前
自定义注解+Lua脚本实现限流
java·spring boot·后端·lua
测试那点事儿1 天前
API 鉴权三种常用做法:用生活例子讲明白
开发语言·lua·生活
QYR-分析1 天前
移动与可穿戴游戏硬件行业发展现状、机遇与前景分析
游戏
远离UE42 天前
UE5 如何在延时渲染在材质编辑器提前使用到多灯光的数据
ue5·编辑器·材质
SCLchuck2 天前
虚幻5 Unrealsharp EditorTick + Nanite雪地踩坑记录
ue5
魔法阵维护师2 天前
从零开发游戏需要学习的c#模块,第二十四章(瓦片地图 —— 让世界有墙)
学习·游戏·c#
tkokof12 天前
捉虫(Bug)再记
游戏·bug·游戏开发
孬甭_2 天前
贪吃蛇游戏 模拟实现
c语言·游戏
sheeta19982 天前
LeetCode 每日一题笔记 日期:2026.05.25 题目:1871. 跳跃游戏 VII
笔记·leetcode·游戏