unreal.StaticMeshEditorSubsystem

class unreal.StaticMeshEditorSubsystem(outer=None, name='None')

Bases: unreal.EditorSubsystem

UStaticMeshEditorSubsystem Subsystem for exposing static mesh functionality to scripts

C++ Source:

  • Module: StaticMeshEditor

  • File: StaticMeshEditorSubsystem.h

add_simple_collisions(static_mesh, shape_type) int32

Same as AddSimpleCollisionsWithNotification but changes are automatically applied.

Parameters
Return type

int32

add_simple_collisions_with_notification(static_mesh, shape_type, apply_changes) int32

Add simple collisions to a static mesh. This method replicates what is done when invoking menu entries “Collision > Add […] Simplified Collision” in the Mesh Editor.

Parameters
  • static_mesh (StaticMesh) – Mesh to generate simple collision for.

  • shape_type (ScriptCollisionShapeType) – Options on which simple collision to add to the mesh.

  • apply_changes (bool) – Indicates if changes must be apply or not.

Returns

An integer indicating the index of the collision newly created. A negative value indicates the addition failed.

Return type

int32

add_uv_channel(static_mesh, lod_index) bool

Adds an empty UV channel at the end of the existing channels on the given LOD of a StaticMesh.

Parameters
  • static_mesh (StaticMesh) – Static mesh on which to add a UV channel.

  • lod_index (int32) – Index of the StaticMesh LOD.

Returns

true if a UV channel was added.

Return type

bool

bulk_set_convex_decomposition_collisions(static_meshes, hull_count, max_hull_verts, hull_precision) bool

Same as SetConvexDecompositionCollisionsWithNotification but changes are automatically applied.

Parameters
  • static_meshes (Array(StaticMesh)) –

  • hull_count (int32) –

  • max_hull_verts (int32) –

  • hull_precision (int32) –

Return type

bool

bulk_set_convex_decomposition_collisions_with_notification(static_meshes, hull_count, max_hull_verts, hull_precision, apply_changes) bool

Compute convex collisions for a set of static meshes. Any existing collisions will be removed from the static meshes. This method replicates what is done when invoking menu entry “Collision > Auto Convex Collision” in the Mesh Editor.

Parameters
  • static_meshes (Array(StaticMesh)) – Set of Static mesh to add convex collision on.

  • hull_count (int32) – Maximum number of convex pieces that will be created. Must be positive.

  • max_hull_verts (int32) – Maximum number of vertices allowed for any generated convex hull.

  • hull_precision (int32) – Number of voxels to use when generating collision. Must be positive.

  • apply_changes (bool) – Indicates if changes must be apply or not.

Returns

A boolean indicating if the addition was successful or not.

Return type

bool

create_proxy_mesh_actor(actors_to_merge, merge_options) StaticMeshActor or None

Build a proxy mesh actor that can replace a set of mesh actors.

Parameters
Returns

Success of the proxy creation

out_merged_actor (StaticMeshActor): generated actor if requested

Return type

StaticMeshActor or None

enable_section_cast_shadow(static_mesh, cast_shadow, lod_index, section_index) None

Enables/disables mesh section shadow casting for a specific LOD.

Parameters
  • static_mesh (StaticMesh) – Static mesh to Enables/disables shadow casting from.

  • cast_shadow (bool) – If the section should cast shadow.

  • lod_index (int32) – Index of the StaticMesh LOD.

  • section_index (int32) – Index of the StaticMesh Section.

enable_section_collision(static_mesh, collision_enabled, lod_index, section_index) None

Enables/disables mesh section collision for a specific LOD.

Parameters
  • static_mesh (StaticMesh) – Static mesh to Enables/disables collisions from.

  • collision_enabled (bool) – If the collision is enabled or not.

  • lod_index (int32) – Index of the StaticMesh LOD.

  • section_index (int32) – Index of the StaticMesh Section.

generate_box_uv_channel(static_mesh, lod_index, uv_channel_index, position, orientation, size) bool

Generates box UV mapping in the specified UV channel on the given LOD of a StaticMesh.

Parameters
  • static_mesh (StaticMesh) – Static mesh on which to generate the UV mapping.

  • lod_index (int32) – Index of the StaticMesh LOD.

  • uv_channel_index (int32) – Channel where to save the UV mapping.

  • position (Vector) – Position of the center of the projection gizmo.

  • orientation (Rotator) – Rotation to apply to the projection gizmo.

  • size (Vector) – The size of the box projection gizmo.

Returns

true if the UV mapping was generated.

Return type

bool

generate_cylindrical_uv_channel(static_mesh, lod_index, uv_channel_index, position, orientation, tiling) bool

Generates cylindrical UV mapping in the specified UV channel on the given LOD of a StaticMesh.

Parameters
  • static_mesh (StaticMesh) – Static mesh on which to generate the UV mapping.

  • lod_index (int32) – Index of the StaticMesh LOD.

  • uv_channel_index (int32) – Channel where to save the UV mapping.

  • position (Vector) – Position of the center of the projection gizmo.

  • orientation (Rotator) – Rotation to apply to the projection gizmo.

  • tiling (Vector2D) – The UV tiling to use to generate the UV mapping.

Returns

true if the UV mapping was generated.

Return type

bool

generate_planar_uv_channel(static_mesh, lod_index, uv_channel_index, position, orientation, tiling) bool

Generates planar UV mapping in the specified UV channel on the given LOD of a StaticMesh.

Parameters
  • static_mesh (StaticMesh) – Static mesh on which to generate the UV mapping.

  • lod_index (int32) – Index of the StaticMesh LOD.

  • uv_channel_index (int32) – Channel where to save the UV mapping.

  • position (Vector) – Position of the center of the projection gizmo.

  • orientation (Rotator) – Rotation to apply to the projection gizmo.

  • tiling (Vector2D) – The UV tiling to use to generate the UV mapping.

Returns

true if the UV mapping was generated.

Return type

bool

get_collision_complexity(static_mesh) CollisionTraceFlag

Get the Collision Trace behavior of a static mesh

Parameters

static_mesh (StaticMesh) – Mesh to query on.

Returns

the Collision Trace behavior.

Return type

CollisionTraceFlag

get_convex_collision_count(static_mesh) int32

Get number of convex collisions present on a static mesh.

Parameters

static_mesh (StaticMesh) – Mesh to query on.

Returns

An integer representing the number of convex collisions on the input static mesh. An negative value indicates that the command could not be executed. See log for explanation.

Return type

int32

get_lod_build_settings(static_mesh, lod_index) MeshBuildSettings

Copy the build options with the specified LOD build settings.

Parameters
  • static_mesh (StaticMesh) – Mesh to process.

  • lod_index (int32) – The LOD we get the reduction settings.

Returns

out_build_options (MeshBuildSettings): The build settings where we copy the build options.

Return type

MeshBuildSettings

get_lod_count(static_mesh) int32

Get number of LODs present on a static mesh.

Parameters

static_mesh (StaticMesh) – Mesh to process.

Returns

the number of LODs present on the input mesh. An negative value indicates that the command could not be executed. See log for explanation.

Return type

int32

get_lod_group(static_mesh) Name

Get the LODGroup for the specified static mesh

Parameters

static_mesh (StaticMesh) –

Returns

LODGroup

Return type

Name

get_lod_material_slot(static_mesh, lod_index, section_index) int32

Gets the material slot used for a specific LOD section.

Parameters
  • static_mesh (StaticMesh) – Static mesh to get the material index from.

  • lod_index (int32) – Index of the StaticMesh LOD.

  • section_index (int32) – Index of the StaticMesh Section.

Returns

MaterialSlotIndex Index of the material slot used by the section or INDEX_NONE in case of error.

Return type

int32

get_lod_reduction_settings(static_mesh, lod_index) MeshReductionSettings

Copy the reduction options with the specified LOD reduction settings.

Parameters
  • static_mesh (StaticMesh) – Mesh to process.

  • lod_index (int32) – The LOD we get the reduction settings.

Returns

out_reduction_options (MeshReductionSettings): The reduction settings where we copy the reduction options.

Return type

MeshReductionSettings

get_lod_screen_sizes(static_mesh)

Get an array of LOD screen sizes for evaluation.

Parameters

static_mesh (StaticMesh) – Mesh to process.

Returns

array of LOD screen sizes.

Return type

Array(float)

get_nanite_settings(static_mesh) MeshNaniteSettings

Get the Nanite Settings for the mesh

Parameters

static_mesh (StaticMesh) – Mesh to access

Returns

FMeshNaniteSettings struct for the given static mesh

Return type

MeshNaniteSettings

get_num_uv_channels(static_mesh, lod_index) int32

Returns the number of UV channels for the given LOD of a StaticMesh.

Parameters
  • static_mesh (StaticMesh) – Static mesh to query.

  • lod_index (int32) – Index of the StaticMesh LOD.

Returns

the number of UV channels.

Return type

int32

get_number_materials(static_mesh) int32

Get number of Materials for a StaticMesh

Parameters

static_mesh (StaticMesh) –

Return type

int32

get_number_verts(static_mesh, lod_index) int32

Get number of StaticMesh verts for an LOD

Parameters
  • static_mesh (StaticMesh) –

  • lod_index (int32) –

Return type

int32

get_simple_collision_count(static_mesh) int32

Get number of simple collisions present on a static mesh.

Parameters

static_mesh (StaticMesh) – Mesh to query on.

Returns

An integer representing the number of simple collisions on the input static mesh. An negative value indicates that the command could not be executed. See log for explanation.

Return type

int32

has_instance_vertex_colors(static_mesh_component) bool

Check whether a static mesh component has vertex colors

Parameters

static_mesh_component (StaticMeshComponent) –

Return type

bool

has_vertex_colors(static_mesh) bool

Check whether a static mesh has vertex colors

Parameters

static_mesh (StaticMesh) –

Return type

bool

import_lod(base_static_mesh, lod_index, source_filename) int32

Import or re-import a LOD into the specified base mesh. If the LOD do not exist it will import it and add it to the base static mesh. If the LOD already exist it will re-import the specified LOD.

Parameters
  • base_static_mesh (StaticMesh) –

  • lod_index (int32) –

  • source_filename (str) –

Returns

the index of the LOD that was imported or re-imported. Will return INDEX_NONE if anything goes bad.

Return type

int32

insert_uv_channel(static_mesh, lod_index, uv_channel_index) bool

Inserts an empty UV channel at the specified channel index on the given LOD of a StaticMesh.

Parameters
  • static_mesh (StaticMesh) – Static mesh on which to insert a UV channel.

  • lod_index (int32) – Index of the StaticMesh LOD.

  • uv_channel_index (int32) – Index where to insert the UV channel.

Returns

true if a UV channel was added.

Return type

bool

is_section_collision_enabled(static_mesh, lod_index, section_index) bool

Checks if a specific LOD mesh section has collision.

Parameters
  • static_mesh (StaticMesh) – Static mesh to remove collisions from.

  • lod_index (int32) – Index of the StaticMesh LOD.

  • section_index (int32) – Index of the StaticMesh Section.

Returns

True is the collision is enabled for the specified LOD of the StaticMesh section.

Return type

bool

join_static_mesh_actors(actors_to_join, join_options) Actor

Create a new Actor in the level that contains a duplicate of all the Actors Static Meshes Component. The ActorsToJoin need to be in the same Level. This will have a low impact on performance but may help the edition by grouping the meshes under a single Actor.

Parameters
Returns

The new created actor.

Return type

Actor

merge_static_mesh_actors(actors_to_merge, merge_options) StaticMeshActor or None

Merge the meshes into a unique mesh with the provided StaticMeshActors. There are multiple options on how to merge the meshes and their materials. The ActorsToMerge need to be in the same Level. This may have a high impact on performance depending of the MeshMergingSettings options.

Parameters
Returns

if the operation is successful.

out_merged_actor (StaticMeshActor): The new created actor, if requested.

Return type

StaticMeshActor or None

reimport_all_custom_lo_ds(static_mesh) bool

Re-import all the custom LODs present in the specified static mesh.

Parameters

static_mesh (StaticMesh) –

Returns

true if re-import all LODs works, false otherwise see log for explanation.

Return type

bool

remove_collisions(static_mesh) bool

Same as RemoveCollisionsWithNotification but changes are applied.

Parameters

static_mesh (StaticMesh) –

Return type

bool

remove_collisions_with_notification(static_mesh, apply_changes) bool

Remove collisions from a static mesh. This method replicates what is done when invoking menu entries “Collision > Remove Collision” in the Mesh Editor.

Parameters
  • static_mesh (StaticMesh) – Static mesh to remove collisions from.

  • apply_changes (bool) – Indicates if changes must be apply or not.

Returns

A boolean indicating if the removal was successful or not.

Return type

bool

remove_lods(static_mesh) bool

Remove LODs on a static mesh except LOD 0.

Parameters

static_mesh (StaticMesh) – Mesh to remove LOD from.

Returns

A boolean indicating if the removal was successful, true, or not.

Return type

bool

remove_uv_channel(static_mesh, lod_index, uv_channel_index) bool

Removes the UV channel at the specified channel index on the given LOD of a StaticMesh.

Parameters
  • static_mesh (StaticMesh) – Static mesh on which to remove the UV channel.

  • lod_index (int32) – Index of the StaticMesh LOD.

  • uv_channel_index (int32) – Index where to remove the UV channel.

Returns

true if the UV channel was removed.

Return type

bool

replace_mesh_components_materials(mesh_components, material_to_be_replaced, new_material) None

Find the references of the material MaterialToReplaced on all the MeshComponents provided and replace it by NewMaterial.

Parameters
replace_mesh_components_materials_on_actors(actors, material_to_be_replaced, new_material) None

Find the references of the material MaterialToReplaced on all the MeshComponents of all the Actors provided and replace it by NewMaterial.

Parameters
replace_mesh_components_meshes(mesh_components, mesh_to_be_replaced, new_mesh) None

Find the references of the mesh MeshToBeReplaced on all the MeshComponents provided and replace it by NewMesh. The editor should not be in play in editor mode.

Parameters
replace_mesh_components_meshes_on_actors(actors, mesh_to_be_replaced, new_mesh) None

Find the references of the mesh MeshToBeReplaced on all the MeshComponents of all the Actors provided and replace it by NewMesh.

Parameters
  • actors (Array(Actor)) – List of Actors to search from.

  • mesh_to_be_replaced (StaticMesh) – Mesh we want to replace.

  • new_mesh (StaticMesh) – Mesh to replace MeshToBeReplaced by.

set_allow_cpu_access(static_mesh, allow_cpu_access) None

Sets StaticMeshFlag bAllowCPUAccess

Parameters
set_convex_decomposition_collisions(static_mesh, hull_count, max_hull_verts, hull_precision) bool

Same as SetConvexDecompositionCollisionsWithNotification but changes are automatically applied.

Parameters
  • static_mesh (StaticMesh) –

  • hull_count (int32) –

  • max_hull_verts (int32) –

  • hull_precision (int32) –

Return type

bool

set_convex_decomposition_collisions_with_notification(static_mesh, hull_count, max_hull_verts, hull_precision, apply_changes) bool

Add a convex collision to a static mesh. Any existing collisions will be removed from the static mesh. This method replicates what is done when invoking menu entry “Collision > Auto Convex Collision” in the Mesh Editor.

Parameters
  • static_mesh (StaticMesh) – Static mesh to add convex collision on.

  • hull_count (int32) – Maximum number of convex pieces that will be created. Must be positive.

  • max_hull_verts (int32) – Maximum number of vertices allowed for any generated convex hull.

  • hull_precision (int32) – Number of voxels to use when generating collision. Must be positive.

  • apply_changes (bool) – Indicates if changes must be apply or not.

Returns

A boolean indicating if the addition was successful or not.

Return type

bool

set_generate_lightmap_uv(static_mesh, generate_lightmap_u_vs) bool

Set Generate Lightmap UVs for StaticMesh

Parameters
Return type

bool

set_lod_build_settings(static_mesh, lod_index, build_options) None

Set the LOD build options for the specified LOD index.

Parameters
  • static_mesh (StaticMesh) – Mesh to process.

  • lod_index (int32) – The LOD we will apply the build settings.

  • build_options (MeshBuildSettings) – The build settings we want to apply to the LOD.

set_lod_from_static_mesh(destination_static_mesh, destination_lod_index, source_static_mesh, source_lod_index, reuse_existing_material_slots) int32

Adds or create a LOD at DestinationLodIndex using the geometry from SourceStaticMesh SourceLodIndex

Parameters
  • destination_static_mesh (StaticMesh) – The static mesh to set the LOD in.

  • destination_lod_index (int32) – The index of the LOD to set.

  • source_static_mesh (StaticMesh) – The static mesh to get the LOD from.

  • source_lod_index (int32) – The index of the LOD to get.

  • reuse_existing_material_slots (bool) – If true, sections from SourceStaticMesh will be remapped to match the material slots of DestinationStaticMesh when they have the same material assigned. If false, all material slots of SourceStaticMesh will be appended in DestinationStaticMesh.

Returns

The index of the LOD that was set. It can be different than DestinationLodIndex if it wasn’t a valid index. A negative value indicates that the LOD was not set. See log for explanation.

Return type

int32

set_lod_group(static_mesh, lod_group, rebuild_immediately=True) bool

Set the LODGroup for the specified static mesh

Parameters
  • static_mesh (StaticMesh) – Mesh to process.

  • lod_group (Name) – Name of the LODGroup to apply

  • rebuild_immediately (bool) – If true, rebuild the static mesh immediately

Returns

Success

Return type

bool

set_lod_material_slot(static_mesh, material_slot_index, lod_index, section_index) None

Sets the material slot for a specific LOD.

Parameters
  • static_mesh (StaticMesh) – Static mesh to Enables/disables shadow casting from.

  • material_slot_index (int32) – Index of the material slot to use.

  • lod_index (int32) – Index of the StaticMesh LOD.

  • section_index (int32) – Index of the StaticMesh Section.

set_lod_reduction_settings(static_mesh, lod_index, reduction_options) None

Set the LOD reduction for the specified LOD index.

Parameters
  • static_mesh (StaticMesh) – Mesh to process.

  • lod_index (int32) – The LOD we will apply the reduction settings.

  • reduction_options (MeshReductionSettings) – The reduction settings we want to apply to the LOD.

set_lods(static_mesh, reduction_options) int32

Same as SetLodsWithNotification but changes are applied.

Parameters
Return type

int32

set_lods_with_notification(static_mesh, reduction_options, apply_changes) int32

Remove then add LODs on a static mesh. The static mesh must have at least LOD 0. The LOD 0 of the static mesh is kept after removal. The build settings of LOD 0 will be applied to all subsequent LODs.

Parameters
  • static_mesh (StaticMesh) – Mesh to process.

  • reduction_options (StaticMeshReductionOptions) – Options on how to generate LODs on the mesh.

  • apply_changes (bool) – Indicates if change must be notified.

Returns

the number of LODs generated on the input mesh. An negative value indicates that the reduction could not be performed. See log for explanation. No action will be performed if ReductionOptions.ReductionSettings is empty

Return type

int32

set_nanite_settings(static_mesh, nanite_settings, apply_changes=True) None

Get the Nanite Settings for the mesh

Parameters
  • static_mesh (StaticMesh) – Mesh to up[date nanite settings for

  • nanite_settings (MeshNaniteSettings) – Settings with which to update the mesh

  • apply_changes (bool) – Indicates if changes must be applied or not.