Skip to content

Commit d7cccd9

Browse files
author
Roberto De Ioris
authored
Update Level_API.md
1 parent 71ddadf commit d7cccd9

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

docs/Level_API.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,29 @@ To attach a level to a world you can use the following function:
6868
import unreal_engine as ue
6969

7070
# note we pass the name of the asset instead of the uobject !
71-
added_level = ue.add_level_to_world(main_world, child_world1.get_path_name()[, always_loaded])
71+
# returns a ULevelStreaming, if you want to retrieve a ULevel from ULevelStreaming, use the 'LoadedLevel' property
72+
added_streaming_level = ue.add_level_to_world(main_world, child_world1.get_path_name()[, always_loaded])
7273
```
7374

7475
Remember that you need to pass the asset path of the world you want to attach !
7576

7677
The always_loaded optional boolean parameter, if set, will add a persistent level instead of a streaming one (it means whenever you load the main_world even child_world1 will be enabled too)
7778

79+
# The "CurrentLevel" concept
7880

81+
Each world has the concept of the "current level". As an example, when you call actor_spawn() on a world, the actor will be effectively spawned in the world that is marked as the current level:
7982

83+
```python
84+
# get a reference to the current level
85+
current_level = ue.get_editor_world().get_current_level()
86+
87+
# change the current level
88+
ue.get_editor_world().set_current_level(child_level1)
89+
90+
# spawn an actor in editor world, but effectively it will be spawned
91+
# in a child level
92+
actor001 = ue.get_editor_world().actor_spawn(actor001)
93+
94+
# back to the original level
95+
ue.get_editor_world().set_current_level(current_level)
96+
```

0 commit comments

Comments
 (0)