Unreal PythonScriptPlugin

编程入门 行业动态 更新时间:2024-10-28 09:20:30

<a href=https://www.elefans.com/category/jswz/34/1745733.html style=Unreal PythonScriptPlugin"/>

Unreal PythonScriptPlugin

Unreal PythonScriptPlugin

文章目录

  • Unreal PythonScriptPlugin
    • Python vs UnLua
    • 官方文档
    • PyStub
    • DoString

示例代码,引擎里有很多插件已经用 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

写小范围的脚本还可以,但是。。

官方文档

.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的

更多推荐

Unreal PythonScriptPlugin

本文发布于:2023-11-16 11:37:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619966.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Unreal   PythonScriptPlugin

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!