示例#1
0
        public virtual void BuildLauncher(BuildTarget TargetTestPlatform)
        {
            MonsterDebug.Log("Building launcher for platform " + TargetTestPlatform);

            string MethodName = GetBuildMethodName(TargetTestPlatform);

            if (MethodName == "")
            {
                MonsterDebug.LogError("Test platform " + TargetTestPlatform + " is not supported yet.  Please add support for it!");
            }

            string MonsterLauncherProjectPath = Path.Combine(Application.temporaryCachePath, "MonsterLauncher");

            MonsterDebug.Log("Creating new project at " + MonsterLauncherProjectPath);

            if (Directory.Exists(MonsterLauncherProjectPath))
            {
                MonsterDebug.Log("Cleaning up old project first!");

                IgorRuntimeUtils.DeleteDirectory(MonsterLauncherProjectPath);
            }

            Directory.CreateDirectory(MonsterLauncherProjectPath);

            string LauncherProjectAssetsIgorFolder = Path.Combine(MonsterLauncherProjectPath, Path.Combine("Assets", "Igor"));

            Directory.CreateDirectory(LauncherProjectAssetsIgorFolder);

            MonsterDebug.Log("Copying project files.");

            IgorRuntimeUtils.DirectoryCopy(Path.Combine(Path.GetFullPath("."), Path.Combine("Assets", "Igor")), LauncherProjectAssetsIgorFolder, true);

            string OldLaunchersFolder = Path.Combine(LauncherProjectAssetsIgorFolder, Path.Combine("Monster", "Launchers"));

            IgorRuntimeUtils.DeleteDirectory(OldLaunchersFolder);

            MonsterDebug.Log("Copying Igor config.");

            string StreamingAssetsFolder = Path.Combine(MonsterLauncherProjectPath, Path.Combine("Assets", Path.Combine("StreamingAssets", "Igor")));

            Directory.CreateDirectory(StreamingAssetsFolder);

            if (File.Exists(IgorConfig.DefaultConfigPath))
            {
                IgorRuntimeUtils.CopyFile(IgorConfig.DefaultConfigPath, Path.Combine(StreamingAssetsFolder, IgorConfig.IgorConfigFilename));
            }

            string BuildLauncherOutput = "";
            string BuildLauncherError  = "";

            MonsterDebug.Log("Attempting to build launcher.");

            int ReturnCode = IgorRuntimeUtils.RunProcessCrossPlatform(EditorApplication.applicationPath + "/Contents/MacOS/Unity", EditorApplication.applicationPath,
                                                                      "-projectPath \"" + MonsterLauncherProjectPath + "\" -buildmachine -executeMethod " + MethodName + " -logfile Monster.log",
                                                                      MonsterLauncherProjectPath, ref BuildLauncherOutput, ref BuildLauncherError);

            if (ReturnCode != 0)
            {
                MonsterDebug.LogError("Something went wrong with the build!  Returned error code " + ReturnCode + "\n\nOutput:\n" + BuildLauncherOutput + "\n\nError:\n" + BuildLauncherError);

                return;
            }

            MonsterDebug.Log("Launcher successfully built!");

            string MonsterLauncherPath = Path.Combine(MonsterTestCore.MonsterLocalDirectoryRoot, "Launchers");

            if (!Directory.Exists(MonsterLauncherPath))
            {
                Directory.CreateDirectory(MonsterLauncherPath);
            }

            MonsterDebug.Log("Copying launcher back to project.");

            CopyLauncherToProjectPath(TargetTestPlatform, MonsterLauncherProjectPath, MonsterLauncherPath);

            IgorRuntimeUtils.DeleteDirectory(MonsterLauncherProjectPath);

            string MonsterRunPyFile = Path.Combine(MonsterLauncherPath, "MonsterRun.py");

            if (File.Exists(MonsterRunPyFile))
            {
                IgorRuntimeUtils.DeleteFile(MonsterRunPyFile);
            }

            string MonsterRunPyFileLatest = Path.Combine(IgorUpdater.LocalModuleRoot, Path.Combine("MonsterTest", Path.Combine("Core", Path.Combine("Runtime", "MonsterRun.py"))));

            if (File.Exists(MonsterRunPyFileLatest))
            {
                MonsterDebug.Log("Copying latest MonsterRun.py to the Launchers folder.");

                IgorRuntimeUtils.CopyFile(MonsterRunPyFileLatest, MonsterRunPyFile);
            }

            MonsterDebug.Log("Done building launcher for platform " + TargetTestPlatform);
        }
示例#2
0
        public virtual bool InternalBuildTestable(bool bRunningTestInEditor = false)
        {
            if (!bRunningTestInEditor)
            {
                if (!IgorSetScriptingDefines.ExtraModuleParams.Contains("MONSTER_TEST_RUNTIME"))
                {
                    IgorSetScriptingDefines.ExtraModuleParams += ";MONSTER_TEST_RUNTIME";
                }

                if (!IgorSetScriptingDefines.ExtraModuleParams.Contains("IGOR_RUNTIME"))
                {
                    IgorSetScriptingDefines.ExtraModuleParams += ";IGOR_RUNTIME";
                }

                IgorJobConfig.SetStringParam(LastDisplayResolutionDialogFlag, PlayerSettings.displayResolutionDialog.ToString());

                PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled;
            }

            if (!bRunningTestInEditor || (TestRunnerInst.CurrentTest != null && TestRunnerInst.CurrentTest.bForceLoadToFirstSceneInEditor))
            {
                string FirstLevelName = IgorUtils.GetFirstLevelName();

                if (FirstLevelName != "")
                {
                    if (EditorApplication.currentScene != FirstLevelName)
                    {
                        EditorApplication.OpenScene(FirstLevelName);

                        return(false);
                    }
                }
            }

            if (MonsterStarter.GetInstance() == null)
            {
                GameObject MonsterStarterInst = new GameObject("MonsterTestStarter");

                MonsterStarterInst.AddComponent <MonsterStarter>();

                EditorApplication.SaveScene();
            }

            if (!bRunningTestInEditor)
            {
                string StreamingAssetsFolder = Path.Combine("Assets", Path.Combine("StreamingAssets", Path.Combine("Igor", Path.Combine("Monster", "Config"))));

                if (Directory.Exists(StreamingAssetsFolder))
                {
                    MonsterDebug.LogError("Attempting to overwrite the " + StreamingAssetsFolder + ", but it already exists!");

                    IgorRuntimeUtils.DeleteDirectory(StreamingAssetsFolder);

                    Directory.CreateDirectory(StreamingAssetsFolder);
                }
                else
                {
                    Directory.CreateDirectory(StreamingAssetsFolder);
                }

                string ConfigRoot = Path.Combine(MonsterTestCore.MonsterLocalDirectoryRoot, "Config");

                if (Directory.Exists(ConfigRoot))
                {
                    IgorRuntimeUtils.DirectoryCopy(ConfigRoot, StreamingAssetsFolder, true);
                }
            }

            return(true);
        }
示例#3
0
 public virtual void CopyActivityOverrideSourceFiles(string RootDirectory)
 {
     IgorRuntimeUtils.DirectoryCopy(Path.Combine(".", Path.Combine("Assets", Path.Combine("Plugins", Path.Combine("Android", "src")))), Path.Combine(RootDirectory, Path.Combine(PlayerSettings.productName, "src")), true);
 }