|
| 1 | +import unreal_engine as ue |
| 2 | + |
| 3 | +from unreal_engine import SWindow, SButton, STextBlock, SEditableTextBox, SMultiLineEditableText, SGridPanel, SHorizontalBox, SPythonEditorViewport |
| 4 | +from unreal_engine.classes import Blueprint |
| 5 | + |
| 6 | +def clicked(geometry, pointer_event): |
| 7 | + ue.log('Hello') |
| 8 | + ue.log(geometry.fields()) |
| 9 | + ue.log(pointer_event.fields()) |
| 10 | + return True |
| 11 | + |
| 12 | +def clicked2(): |
| 13 | + ue.log('Test') |
| 14 | + return True |
| 15 | + |
| 16 | +window = SWindow().resize(1024, 576).set_title('Hello World') |
| 17 | + |
| 18 | +horizontal = SHorizontalBox() |
| 19 | + |
| 20 | +button = SButton().set_content(STextBlock().set_text('Click ME !')) |
| 21 | +button.bind_on_mouse_button_down(clicked) |
| 22 | +button.bind_on_clicked(clicked2) |
| 23 | + |
| 24 | +box = SEditableTextBox() |
| 25 | + |
| 26 | +editor = SMultiLineEditableText() |
| 27 | +editor.set_text('Hello') |
| 28 | + |
| 29 | +grid = SGridPanel() |
| 30 | + |
| 31 | +grid.add_slot(button, 0, 0) |
| 32 | +grid.add_slot(box, 0, 1) |
| 33 | +grid.add_slot(editor, 0, 2) |
| 34 | + |
| 35 | +horizontal.add_slot(grid, v_align=2, h_align=2).add_slot(STextBlock().set_text('Second'), v_align=2, h_align=2) |
| 36 | + |
| 37 | +viewport = SPythonEditorViewport() |
| 38 | + |
| 39 | +world = viewport.get_world() |
| 40 | +bear_bp = ue.load_object(Blueprint, '/Game/Character3_Blueprint') |
| 41 | + |
| 42 | +bear = world.actor_spawn(bear_bp.GeneratedClass) |
| 43 | + |
| 44 | +horizontal.add_slot(viewport) |
| 45 | + |
| 46 | +window.set_content(horizontal) |
0 commit comments