Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .clone() to prevent crash with SourceModels[0] #792

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/Slate_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,31 @@ Check this example: https://github.com/20tab/UnrealEnginePython/blob/master/exam

It shows even how to register new style sets.

## SPythonComboBox

```python
from unreal_engine import SWindow, STextBlock, SPythonComboBox

def generate_combo_box_widget(item):
return STextBlock(text=item)

def get_current_item():
return combo_box.get_selected_item()

def on_selection_changed(item, index):
print ('New selection: %s, %s' % (item, index))

items = ['spam', 'ham', 'eggs']
combo_box = SPythonComboBox(options_source=items, on_generate_widget=generate_combo_box_widget, content=STextBlock(text=get_current_item), on_selection_changed=on_selection_changed)
combo_box.set_selected_item(items[0])

SWindow(client_size=(300,30))(
combo_box
)
```

![SDetailView](screenshots/slate_SPythonComboBox.png)

## SPythonListView

## SPythonTreeView
Expand Down
Binary file added docs/screenshots/slate_SPythonComboBox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tutorials/SnippetsForStaticAndSkeletalMeshes.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def fix_pivot(static_mesh):
raw_mesh.set_vertex_positions(updated_positions)

# assign the mesh data to the first LOD (LODs are exposed in SourceModels array)
raw_mesh.save_to_static_mesh_source_model(new_static_mesh.SourceModels[0])
raw_mesh.save_to_static_mesh_source_model(new_static_mesh.SourceModels[0].clone())
# rebuild the whole mesh
new_static_mesh.static_mesh_build()
# re-do the body setup (collisions and friends)
Expand Down Expand Up @@ -171,7 +171,7 @@ def add_lods(static_mesh):
raw_mesh.save_to_static_mesh_source_model(lod2)

# assign the new LODs (leaving the first one untouched)
new_static_mesh.SourceModels = [new_static_mesh.SourceModels[0], lod1, lod2]
new_static_mesh.SourceModels = [new_static_mesh.SourceModels[0].clone(), lod1, lod2]
# rebuild the whole mesh
new_static_mesh.static_mesh_build()
# re-do the body setup (collisions and friends)
Expand Down