您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
29 行
841 B
29 行
841 B
using System;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
namespace MLAgents
|
|
{
|
|
public class Startup: MonoBehaviour
|
|
{
|
|
void Awake()
|
|
{
|
|
string sceneName = Environment.GetEnvironmentVariable("SCENE_NAME");
|
|
SwitchScene(sceneName);
|
|
}
|
|
|
|
private static void SwitchScene(string sceneName)
|
|
{
|
|
if (sceneName == null)
|
|
{
|
|
throw new ArgumentException("You didn't specified the SCENE_NAME environment variable");
|
|
}
|
|
if (SceneUtility.GetBuildIndexByScenePath(sceneName) < 0)
|
|
{
|
|
throw new ArgumentException("The scene " + sceneName + " doesn't exist within your build. ");
|
|
}
|
|
SceneManager.LoadSceneAsync(sceneName);
|
|
}
|
|
}
|
|
}
|