UE4 Python editor

2022-04-02  本文已影响0人  Moo2077

1.插件导入

2.python import脚本问题

在设置里加入新的文件夹当做引用文件夹,同时重启编辑器
这样就能在代码里import这个文件夹的其他文件了


image.png

3.API

官网API:没有这个寸步难行
https://docs.unrealengine.com/4.26/en-US/PythonAPI/

4.使用案例

actors = unreal.EditorLevelLibrary.get_selected_level_actors()

创建一个actor

position = unreal.Vector(0,0,0)
rotation = unreal.Quat(0,0,0,1)
cube = unreal.EditorLevelLibrary.spawn_actor_from_class(unreal.StaticMeshActor,position,rotation.rotator())

检测射线碰撞

position = unreal.Vector(0,0,0)
end_position = unreal.Vector(1000,0,0)
actors_ignore = []
hit = unreal.SystemLibrary().line_trace_single(unreal.EditorLevelLibrary().get_editor_world(),position,end_position,unreal.TraceTypeQuery.TRACE_TYPE_QUERY1,True,actors_ignore,unreal.DrawDebugTrace.NONE,True) # PERSISTENT

例如加载某些资源

    mesh = unreal.EditorAssetLibrary.load_asset('/Engine/BasicShapes/Cube.Cube')
    material = unreal.EditorAssetLibrary.load_asset('/Engine/BasicShapes/BasicShapeMaterial.BasicShapeMaterial')
上一篇 下一篇

猜你喜欢

热点阅读