运行 Schola
Schola 使用 UnrealConnection 的子类与 Unreal Engine 进行交互。它支持创建作为 Python 脚本子进程运行的独立 Unreal Engine 实例,或者连接到正在运行的 Unreal Engine 进程。
从 Python 启动 Unreal 环境
Schola 支持使用 StandaloneUnrealConnection 完全从 Python 运行环境。
from schola.core.unreal_connection import StandaloneConnection
url="localhost" # Connect to the engine over localhostue_path="Path to your Game Binary"port=None # Leave blank to use an arbitrary open portheadless_mode = True # Should we skip rendering the Unreal Engine game?display_logs = False # Should we open a terminal to show Unreal Engine logs?_map=None # Run the default map for the selected executable, set to "/game/<path to map>" to use a different map.set_fps=60 # Set a fixed framerate for the game.disable_script=True # Ignore the RunScriptOnLaunch setting for the UnrealEngineGame.
unreal_connection = StandaloneConnection(url=url, port=port, headless_mode=headless_mode, display_logs=display_logs, map=_map, set_fps=set_fps)初始化环境
from schola.gym.env import VecEnvfrom schola.core.unreal_connection import StandaloneConnection
unreal_connection = StandaloneConnection("localhost","Path To Game Binaries", headless_mode=True)env = VecEnv(unreal_connection)... # Your Code Herefrom schola.ray.env import BaseEnvfrom schola.core.unreal_connection import StandaloneConnection
unreal_connection = StandaloneConnection("localhost","Path To Game Binaries", headless_mode=True)env = BaseEnv(unreal_connection)... # Your Code Herefrom schola.sb3.env import VecEnvfrom schola.core.unreal_connection import StandaloneConnection
unreal_connection = StandaloneConnection("localhost","Path To Game Binaries", headless_mode=True)env = VecEnv(unreal_connection)... # Your Code Here连接到正在运行的 Unreal 环境
Schola 支持使用 UnrealEditorConnection 连接到已在运行的编辑器或游戏,用于调试和 Unreal Engine 驱动的工作流。
from schola.core.unreal_connection import UnrealEditorConnection
url="localhost" # Connect to the engine over localhostport=8002 # Must match the port selected in your Unreal Engine Plugin Settings for Schola
unreal_connection = UnrealEditorConnection(url, port)初始化环境
from schola.gym.env import VecEnvfrom schola.core.unreal_connection import UnrealEditorConnection
unreal_connection = UnrealEditorConnection("localhost",8002)env = VecEnv(unreal_connection)... # Your Code Herefrom schola.ray.env import BaseEnvfrom schola.core.unreal_connection import UnrealEditorConnection
unreal_connection = UnrealEditorConnection("localhost",8002)env = BaseEnv(unreal_connection)... # Your Code Herefrom schola.sb3.env import VecEnvfrom schola.core.unreal_connection import UnrealEditorConnection
unreal_connection = UnrealEditorConnection("localhost",8002)env = VecEnv(unreal_connection)... # Your Code Here