Download

How to convert an "asset path" to a "os/system path" in Python?

What is the “correct” way to do this in Python, so that it also works for directories not starting with “/Game/” (for example, content-only plugins)?

unreal_paths = unreal.Paths()
CONTENT_DIR = unreal_paths.project_content_dir()
PROJECT_DIR = unreal_paths.project_dir()
# ...
def game_path_to_os_path(path):
	if path.startswith("/Game/"):
		return CONTENT_DIR+path[6:]
	idx = path.index('/', 1)
	return PROJECT_DIR+'Plugins/'+path[1:idx]+'/Content'+path[idx:]