unreal.EditorLevelLibrary

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

Bases: unreal.BlueprintFunctionLibrary

Utility class to do most of the common functionalities in the World Editor. The editor should not be in play in editor mode.

C++ Source:

  • Plugin: EditorScriptingUtilities

  • Module: EditorScriptingUtilities

  • File: EditorLevelLibrary.h

classmethod clear_actor_selection_set()None

Remove all actors from the selection set

classmethod convert_actors(actors, actor_class, static_mesh_package_path)

Replace in the level all Actors provided with a new actor of type ActorClass. Destroy all Actors provided.

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

  • actor_class (type(Class)) – Class/Blueprint of the new actor that will be spawn.

  • static_mesh_package_path (str) – If the list contains Brushes and it is requested to change them to StaticMesh, StaticMeshPackagePath is the package path to where the StaticMesh will be created. ie. /Game/MyFolder/

Returns

Return type

Array(Actor)

classmethod 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

classmethod destroy_actor(actor_to_destroy)bool

Destroy the actor from the world editor. Notify the Editor that the actor got destroyed.

Parameters

actor_to_destroy (Actor) –

Returns

True if the operation succeeds.

Return type

bool

classmethod editor_end_play()None

Editor End Play

classmethod editor_invalidate_viewports()None

Editor Invalidate Viewports

classmethod editor_play_simulate()None

Editor Play Simulate

classmethod editor_set_game_view(game_view)None

Editor Set Game View

Parameters

game_view (bool) –

classmethod eject_pilot_level_actor()None

Eject Pilot Level Actor

classmethod get_actor_reference(path_to_actor)Actor

Attempts to find the actor specified by PathToActor in the current editor world

Parameters

path_to_actor (str) – The path to the actor (e.g. PersistentLevel.PlayerStart)

Returns

A reference to the actor, or none if it wasn’t found

Return type

Actor

classmethod get_all_level_actors()

Find all loaded Actors in the world editor. Exclude actor that are pending kill, in PIE, PreviewEditor, …

Returns

List of found Actors

Return type

Array(Actor)

classmethod get_all_level_actors_components()

Find all loaded ActorComponent own by an actor in the world editor. Exclude actor that are pending kill, in PIE, PreviewEditor, …

Returns

List of found ActorComponent

Return type

Array(ActorComponent)

classmethod get_editor_world()World

Find the World in the world editor. It can then be used as WorldContext by other libraries like GameplayStatics.

Returns

The World used by the world editor.

Return type

World

classmethod get_game_world()World

Get Game World

Returns

Return type

World

classmethod get_level_viewport_camera_info()(camera_location=Vector, camera_rotation=Rotator) or None

Gets information about the camera position for the primary level editor viewport. In non-editor builds, these will be zeroed

Returns

Whether or not we were able to get a camera for a level editing viewport

camera_location (Vector): (out) Current location of the level editing viewport camera, or zero if none found

camera_rotation (Rotator): (out) Current rotation of the level editing viewport camera, or zero if none found

Return type

tuple or None

classmethod get_pie_worlds(include_dedicated_server)

Get PIEWorlds

Parameters

include_dedicated_server (bool) –

Returns

Return type

Array(World)

classmethod get_selected_level_actors()

Find all loaded Actors that are selected in the world editor. Exclude actor that are pending kill, in PIE, PreviewEditor, …

Returns

List of found Actors

Return type

Array(Actor)

classmethod 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

classmethod load_level(asset_path)bool

Close the current Persistent Level (without saving it). Loads the specified level.

Parameters

asset_path (str) – Asset Path of the level to be loaded. ie. /Game/MyFolder/MyAsset

Returns

True if the operation succeeds.

Return type

bool

classmethod 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

classmethod new_level(asset_path)bool

Close the current Persistent Level (without saving it). Create a new blank Level and save it. Load the new created level.

Parameters

asset_path (str) – Asset Path of where the level will be saved. ie. /Game/MyFolder/MyAsset

Returns

True if the operation succeeds.

Return type

bool

classmethod new_level_from_template(asset_path, template_asset_path)bool

Close the current Persistent Level (without saving it). Create a new Level base on another level and save it. Load the new created level.

Parameters
  • asset_path (str) – Asset Path of where the level will be saved. ie. /Game/MyFolder/MyAsset

  • template_asset_path (str) – Level to be used as Template. ie. /Game/MyFolder/MyAsset

Returns

True if the operation succeeds.

Return type

bool

classmethod pilot_level_actor(actor_to_pilot)None

Pilot Level Actor

Parameters

actor_to_pilot (Actor) –

classmethod 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
classmethod 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
classmethod 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
classmethod 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.

classmethod replace_selected_actors(asset_path)None

Replaces the selected Actors with the same number of a different kind of Actor using the specified factory to spawn the new Actors note that only Location, Rotation, Drawscale, Drawscale3D, Tag, and Group are copied from the old Actors

Parameters

asset_path (str) –

classmethod save_all_dirty_levels()bool

Saves all Level currently loaded by the World Editor.

Returns

True if the operation succeeds.

Return type

bool

classmethod save_current_level()bool

Saves the specified Level. Must already be saved at lease once to have a valid path.

Returns

True if the operation succeeds.

Return type

bool

classmethod select_nothing()None

Selects nothing in the editor (another way to clear the selection)

classmethod set_actor_selection_state(actor, should_be_selected)None

Set the selection state for the selected actor

Parameters
  • actor (Actor) –

  • should_be_selected (bool) –

classmethod set_current_level_by_name(level_name)bool

Set the current level used by the world editor. If more than one level shares the same name, the first one encounter of that level name will be used.

Parameters

level_name (Name) – The name of the Level the actor belongs to (same name as in the ContentBrowser).

Returns

True if the operation succeeds.

Return type

bool

classmethod set_level_viewport_camera_info(camera_location, camera_rotation)None

Sets information about the camera position for the primary level editor viewport.

Parameters
  • camera_location (Vector) – Location the camera will be moved to.

  • camera_rotation (Rotator) – Rotation the camera will be set to.

classmethod set_selected_level_actors(actors_to_select)None

Clear the current world editor selection and select the provided actors. Exclude actor that are pending kill, in PIE, PreviewEditor, …

Parameters

actors_to_select (Array(Actor)) – Actor that should be selected in the world editor.

classmethod spawn_actor_from_class(actor_class, location, rotation=[0.0, 0.0, 0.0], transient=False)Actor

Create an actor and place it in the world editor. Can be created from a Blueprint or a Class. The actor will be created in the current level and will be selected.

Parameters
  • actor_class (type(Class)) – Asset to attempt to use for an actor to place.

  • location (Vector) – Location of the new actor.

  • rotation (Rotator) –

  • transient (bool) –

Returns

The created actor.

Return type

Actor

classmethod spawn_actor_from_object(object_to_use, location, rotation=[0.0, 0.0, 0.0], transient=False)Actor

Create an actor and place it in the world editor. The Actor can be created from a Factory, Archetype, Blueprint, Class or an Asset. The actor will be created in the current level and will be selected.

Parameters
  • object_to_use (Object) – Asset to attempt to use for an actor to place.

  • location (Vector) – Location of the new actor.

  • rotation (Rotator) –

  • transient (bool) –

Returns

The created actor.

Return type

Actor