一个奇奇怪怪的扩展,包含各种方便的方法(计划!)
目前有一些Slate,蓝图的扩展
https://github.com/mengxinxiaoqiang/MxUPython
import unreal
@unreal.uclass()
class MainWindow(unreal.MxWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.set_window_title(u"测试窗口")
self.resize(800, 100)
self.open_file_path_button = unreal.MxButton()
self.open_file_path_button.set_text(u"打开文件位置")
self.import_selected_file_button = unreal.MxButton()
self.import_selected_file_button.set_text(u"导入所选文件")
self.TestEditText = unreal.MxEditableText()
ButtonLayout = unreal.MxHorizontalBox()
ButtonLayout.add_widget(self.TestEditText)
ButtonLayout.add_widget(self.open_file_path_button)
MainLayout = unreal.MxVerticalBox()
MainLayout.add_widget(ButtonLayout)
MainLayout.add_widget(self.import_selected_file_button)
self.set_layout(MainLayout)
# 代理必须声明为成员变量,销毁的时候会自动销毁,否则重新生成UI的时候,绑定的函数不会被刷新
self.ButtonClick = unreal.OnMxButtonClick()
self.ButtonClick.bind_callable(self.TestClick)
self.open_file_path_button.on_click_connect(self.ButtonClick)
self.import_selected_file_button.on_click_connect(self.ButtonClick)
def TestClick(self):
print("TestEditText------".format(self.TestEditText.get_text()))
Window = MainWindow()
Window.show()
import unreal
Blueprint = unreal.load_asset("/Game/NewBlueprint.NewBlueprint")
MxBlueprint = unreal.MxUtils.cast_mx_blueprint(Blueprint)
Scene = MxBlueprint.add_component("Test_Scene", unreal.SceneComponent)
AcotrComponent = MxBlueprint.add_component("Test_Mesh", unreal.StaticMeshComponent, "Test_Scene")
AcotrComponent.set_static_mesh(unreal.load_asset("StaticMesh'/Game/StarterContent/Architecture/Wall_Door_400x400.Wall_Door_400x400'"))
AcotrComponent.set_world_location(unreal.Vector(100, 200, 300), False, False)