Python: Getting an reference from path for an actor in a sublevel?

DragonGuard
Thu, 10 Jun 2021 18:32:59 +0000
Editor Scripting

Hello,

I’m working on an editor tool and I’m trying to get an actor reference from a actor path.

According to the Python documentation I can use unreal.EditorLevelLibrary().get_actor_reference(path) for this.
It works fine for anything in my persistent level, but always returns None when trying to get something from a sublevel.

Say I have 2 objects (ActorA,ActorB), one in the persistent level (MAP_Persistent)(ActorA) and another in a sublevel (Map_Art)(ActorB).

If I get the paths for these actors I get something along these lines:

MAP_Persistent.MAP_Persistent:PersistentLevel.ActorA

Map_Art.Map_Art:PersistentLevel.ActorB

If I use unreal.EditorLevelLibrary().get_actor_reference(“PersistentLevel.ActorA”) it works completely fine.
However I’m struggling getting a reference for Actor_B.

I’ve tried:

unreal.EditorLevelLibrary().get_actor_reference(“PersistentLevel.ActorB”)
unreal.EditorLevelLibrary().get_actor_reference(“Map_Art:PersistentLevel.ActorB”)
unreal.EditorLevelLibrary().get_actor_reference(“Map_Art.Map_Art:PersistentLevel.ActorB”)

All of these return None.

I’m guessing this is related to the editor world. The documentation lists that get_actor_reference searches the current editor world. But isn’t my sublevel also part of this world?

How do I go about getting a reference from my ActorB? Am I missing something?

2 posts - 2 participants