Skip to content

Commit 471b315

Browse files
author
Roberto De Ioris
authored
Update WritingAColladaFactoryWithPython.md
1 parent e67551b commit 471b315

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

‎tutorials/WritingAColladaFactoryWithPython.md‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,55 @@ class ColladaFactory(PyFactory):
417417

418418
```
419419

420+
Now every time a ColladaFactory is spawned it will hold a reference to the ColladaImportOptions() instance. In this way the value we enter will be remembered between runs.
421+
422+
Note that we have set a default material to assign to the mesh.
423+
424+
The new open_collada_wizard function is now super-easy as the widget will be automatically generated by the `ue.create_detail_(obj)` function:
425+
426+
```python
427+
def open_collada_wizard(self):
428+
429+
def cancel_import():
430+
self.wizard.request_destroy()
431+
432+
def confirm_import():
433+
self.do_import = True
434+
self.wizard.request_destroy()
435+
436+
self.wizard = SWindow(title='Collada Import Options', modal=True, sizing_rule=1)(
437+
SVerticalBox()
438+
(
439+
ue.create_detail_view(self.ImportOptions),
440+
auto_height=True,
441+
padding = 10
442+
)
443+
(
444+
SHorizontalBox()
445+
(
446+
SButton(text='Cancel', on_clicked=cancel_import, h_align = EHorizontalAlignment.HAlign_Center)
447+
)
448+
(
449+
SButton(text='Import', on_clicked=confirm_import, h_align = EHorizontalAlignment.HAlign_Center)
450+
),
451+
auto_height=True,
452+
padding = 4,
453+
),
454+
455+
)
456+
self.wizard.add_modal()
457+
```
458+
459+
To assign the material to the mesh just add this call before returning the static_mesh:
460+
461+
```python
462+
static_mesh.StaticMaterials = [StaticMaterial(MaterialInterface=self.ImportOptions.DefaultMaterial, MaterialSlotName='Main')]
463+
```
464+
465+
You can download the whole script here:
466+
467+
468+
420469
## Automatically add the ColladaFactory on editor startup
421470

422471
## Improvements and final notes

0 commit comments

Comments
 (0)