如何在运行命令行(Unity3d)的脚本中获取游戏对象(场景中)

如何在运行命令行(Unity3d)的脚本中获取游戏对象(场景中),unity3d,command-line-interface,Unity3d,Command Line Interface,我在Unity3d中使用命令行运行脚本: “C:\ProgramFiles(x86)\Unity\Editor\Unity.exe”-退出-批处理模式-项目路径“路径到项目”-执行方法命令.Do” 在方法“Do”中:我尝试在场景:GameObject.Find(“自动”)中获取GameObject,但结果为null( 我决定: 相反,SceneManager.LoadScene(0)需要使用:EditorSceneManager.OpenScene(scene.path) class Comma

我在Unity3d中使用命令行运行脚本: “C:\ProgramFiles(x86)\Unity\Editor\Unity.exe”-退出-批处理模式-项目路径“路径到项目”-执行方法命令.Do”

在方法“Do”中:我尝试在场景:GameObject.Find(“自动”)中获取GameObject,但结果为null(

我决定: 相反,SceneManager.LoadScene(0)需要使用:EditorSceneManager.OpenScene(scene.path)

class Command
{
   static public void Do()
   {
    Debug.Log("Test");
    EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTarget.Android);

    var scene = EditorBuildSettings.scenes[0];
    string name = scene.path.Substring(scene.path.LastIndexOf('/') + 1);
    name = name.Substring(0, name.Length - 6);

    SceneManager.LoadScene(0);

    var automationGo = GameObject.Find("Automation");
    System.Console.WriteLine("automationGo " + automationGo);
  }
}