-
Notifications
You must be signed in to change notification settings - Fork 757
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
Levels and sub-levels #87
Comments
Wow it was hard, i finally grasped how the whole level structure works. The support is pretty raw but should be a good base: import unreal_engine as ue
from unreal_engine.classes import WorldFactory
factory = WorldFactory()
new_Level = factory.factory_create_new('/Game/NewLevel001') this will create a new level asset (well it is a world !) You can access levels of a world with the new get_levels() function (it returns a list of levels) To add a level to a world: ue.add_level_to_world(world, '/Game/name_of_the_level_asset'[, persistent]) (set persistent as True, if you want your level to be always loaded) Finally to move actors between levels: ue.move_selected_actors_to_level(level) well, this is annoying because it is the same api used in the editor, so it works only for selected actors. Lucky enough we already have the selection api: actor = world.actor_spawn(Actor)
ue.editor_select_actor(actor)
ue.move_selected_actors_to_level(level) absolutely not the most handy api, but currently i do not see too much other solutions |
Many thanks for all your efforts @rdeioris ! Sorry this gave you such a hard time! The level creation bit works great! I'm having a few issues with part that moves the actors to the level though. Sample code I tried: import unreal_engine as ue
from unreal_engine.classes import WorldFactory, StaticMeshActor
world = ue.get_editor_world()
new_Level = WorldFactory().factory_create_new('/Game/Levels/PyLevel')
ue.add_level_to_world(world, '/Game/Levels/PyLevel')
actor = world.actor_spawn(StaticMeshActor)
ue.editor_select_actor(actor)
# This bit crashes
ue.move_actor_to_level(new_Level) Returns: PS. sorry if this sounds stupid, but what is the syntax to make the level persistent? Using ue.add_level_to_world(world, '/Game/Levels/PyLevel', False) or ue.add_level_to_world(world, '/Game/Levels/PyLevel', True) doesn't seem to make a difference - or I'm looking to wrong place. |
Hi, i have fixed the function (both its name and the number of arguments), regarding level persistance take into account that the levels panel does not update when you add levels (i need to investigate how to refresh it). I am checking if i can avoid the selction part |
Awesome! Many thanks @rdeioris, I'll go try it now. Yeah, I've noticed that about the Levels window. I keep closing it and re-opening it for now. |
Hm.. I know get an error saying: import unreal_engine as ue
from unreal_engine.classes import WorldFactory, StaticMeshActor
world = ue.get_editor_world()
new_Level = WorldFactory().factory_create_new('/Game/Levels/PyLevel')
ue.add_level_to_world(world, '/Game/Levels/PyLevel')
actor = world.actor_spawn(StaticMeshActor)
ue.editor_select_actor(actor)
ue.move_selected_actors_to_level(new_Level) |
Hi @rdeioris , I'm bringing up this again. import unreal_engine as ue
from unreal_engine.classes import WorldFactory
world = ue.get_editor_world()
levels = world.get_levels()
for level in levels:
print ("--------------" + level.get_name() + "--------------")
print level.LevelColor I'm getting
I'm guessing it finds the number of levels - as I'm getting three as well - but it doesn't iterate and it only returns the first one. Can you please have a look? |
The level api has been added and documented: https://github.com/20tab/UnrealEnginePython/blob/master/docs/Level_API.md |
Hi there,
Can you please add support to create levels and sub-levels?
I want if possible to be able to create sub-levels to my current level and add actors there.
Cheers,
Nick
The text was updated successfully, but these errors were encountered: