【UE×Python】レベル上のアクターを選択する方法について徹底解説

Python

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

# set_actor_selection_state関数によるレベル上のアクターの選択
unreal.EditorActorSubsystem().set_actor_selection_state(アクター, True)

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

・Unreal Engine上で、どの様にPythonを使うの?
・Unreal Engine上のPythonで、どの様にレベル上のアクターを選択するの?

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

set_actor_selection_state関数によるレベル上のアクターの選択

unreal.EditorActorSubsystem().set_actor_selection_state関数の基本構文

unreal.EditorActorSubsystem().set_actor_selection_state(
	actor: unreal.Actor, 
	should_be_selected: bool
) 
→ None

unreal.EditorActorSubsystem().set_actor_selection_state関数の使い方

import unreal

actor_path = "PersistentLevel.StaticMeshActor_0"
actor = unreal.EditorActorSubsystem().get_actor_reference(actor_path)

unreal.EditorActorSubsystem().set_actor_selection_state(actor, True)

まとめ

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

関連検索ワード

How to select the actor in level?

関連キーワード

unreal, python, select, actor, 選択