【UE×Python】アクティブなゲームレベルを取得する方法について徹底解説

Python

「unreal」(Unreal Engine Python API)は、Unreal EngineのPythonライブラリです。このAPIを使用することで、Unreal Engineをより簡単にカスタマイズすることができます。Pythonは、様々なプログラミング言語で使用される汎用的なスクリプト言語であり、「unreal」はPythonを使用して構築されています。本記事では、「unreal」を用いたアクティブなゲームレベルを取得する方法を紹介します。

# get_game_world関数によるアクティブなゲームレベルの取得
unreal.UnrealEditorSubsystem().get_game_world()

下記の様な内容で悩んでいる/困っている場合に使える方法を参考までにご共有させて頂きます。

・Unreal Engine上で、どの様にPythonを使うの?
・Unreal Engine上のPythonで、どの様にアクティブなゲームレベルを取得するの?

また、「unreal」を使用する上で基礎的な情報は下記の記事で紹介しております。
他の「unreal」のクラスや関数について気になる方はこちらの記事をご覧ください。

get_game_world関数によるアクティブなゲームレベルの取得

unreal.UnrealEditorSubsystem().get_game_world関数の基本構文

unreal.EditorActorSubsystem().get_game_world() 
→ World

unreal.UnrealEditorSubsystem().get_game_world関数の使い方

import unreal

activeGameWorld = unreal.UnrealEditorSubsystem().get_game_world()

### Attribute of "activeGameWorld"
for attribute in dir(activeGameWorld): print(attribute)

### Help of "activeGameWorld"
help(activeGameWorld)

### Information of "activeGameWorld"
print(activeGameWorld.get_class())
print(activeGameWorld.get_fname())
print(activeGameWorld.get_path_name())
LogPython: __class__
LogPython: __delattr__
LogPython: __dir__
...
LogPython: set_editor_properties
LogPython: set_editor_property
LogPython: static_class
LogPython: Help on World object:
class World(Object)
 |  The World is the top level object representing a map or a sandbox in which Actors and Components will exist and be rendered.
...
 |  Static methods inherited from _ObjectBase:
 |  
 |  __new__(*args, **kwargs) from builtins.type
 |      Create and return a new object.  See help(type) for accurate signature.
LogPython: <Object '/Script/Engine.World' (0x00000590DCDB4800) Class 'Class'>
LogPython: LV_Basic
LogPython: /Game/UEDPIE_0_LV_Basic.LV_Basic

メモ

エディタレベル(編集時のレベル):
unreal.UnrealEditorSubsystem().get_editor_world()
ゲームレベル(プレイ時のレベル):
unreal.UnrealEditorSubsystem().get_game_world()

まとめ

「unreal」(Unreal Engine Python API)は、Pythonを使ったUnreal Engineの開発に非常に役立ちます。この記事では、アクティブなゲームレベルを取得する方法を紹介しました。ぜひ活用してみてください。

関連検索ワード

How to get active game level in editor mode?

関連キーワード

unreal, python, get, game, level, レベル, 取得

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny