public static void ExecuteAction(UMakeTarget t, BuildAction action)
        {
            UMake umake;

            if (!UMake.Get().TryGet(out umake))
            {
                return;
            }

            string buildPath;

            UMakeTarget.Path targetPath;

            switch (action)
            {
            case BuildAction.PreActions:
                EditorApplication.delayCall += () => t.ExecutePreBuildActions(umake);
                break;

            case BuildAction.Build:
                buildPath = UMake.GetBuildPath();
                EditorApplication.delayCall += () => t.Build(umake, buildPath);
                break;

            case BuildAction.PostActions:
                EditorApplication.delayCall += () => t.ExecutePostBuildActions(umake);
                break;

            case BuildAction.OpenFolder:
                targetPath = t.GetTargetPath(umake.version, UMake.GetBuildPath());
                EditorUtility.RevealInFinder(targetPath.directoryPath);
                break;
            }
        }
Example #2
0
        public void Build(UMake umake, string buildPath)
        {
            if (string.IsNullOrEmpty(buildPath))
            {
                return;
            }

            ExecutePreBuildActions(umake);

            Path targetPath = GetTargetPath(umake.version, UMake.GetBuildPath());


            if (Directory.Exists(targetPath.directoryPath))
            {
                Directory.Delete(targetPath.directoryPath, true);
                Directory.CreateDirectory(targetPath.directoryPath);
            }


            string[] levels = EditorBuildSettings.scenes.Where(s => s.enabled).Select(s => s.path).ToArray();
            BuildPipeline.BuildPlayer(levels, targetPath.path, buildTarget, buildOptions);
        }
        public override void Execute(UMake umake, UMakeTarget target)
        {
            try
            {
                string buildPath        = UMake.GetBuildPath();
                string steamBuildScript = buildScript;
                if (UMakeCli.IsInCli)
                {
                    UMakeCli.Args.TryGetValue("path", out buildPath);
                    UMakeCli.Args.TryGetValue("script", out steamBuildScript);
                }

                if (!CopyContent(target, umake.version, buildPath))
                {
                    Debug.Log("Could not copy content to Steam folder.");
                    return;
                }

                if (!Directory.Exists(steamSdkPath.Value))
                {
                    Debug.LogFormat("SteamSDK \"{0}\" not found.", steamSdkPath.Value);
                    return;
                }

                string steamCmdPath = GetSteamCmdPath();
                if (!File.Exists(steamCmdPath))
                {
                    Debug.LogFormat("SteamCMD \"{0}\" not found.", steamCmdPath);
                    return;
                }

                var uploaderProcess = new System.Diagnostics.Process();
                uploaderProcess.StartInfo.FileName         = steamCmdPath;
                uploaderProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(Path.GetDirectoryName(steamCmdPath));
                uploaderProcess.StartInfo.Arguments        = string.Format(steamCmdArgFormat, steamUsername.Value, steamPassword.Value, steamBuildScript);

                if (UMakeCli.IsInCli)
                {
                    uploaderProcess.StartInfo.UseShellExecute        = false;
                    uploaderProcess.StartInfo.RedirectStandardOutput = true;
                    uploaderProcess.OutputDataReceived += (sender, msg) =>
                    {
                        if (msg != null)
                        {
                            Debug.Log(msg.Data);
                        }
                    };
                }

                uploaderProcess.Start();
                Debug.LogFormat("Executing SteamCMD \"{0}\"...", steamCmdPath);

                if (UMakeCli.IsInCli)
                {
                    uploaderProcess.BeginOutputReadLine();
                    uploaderProcess.WaitForExit();
                }

                uploaderProcess.Close();
            }
            catch (System.Exception e)
            {
                Debug.Log("Upload to Steam failed.");
                Debug.LogException(e);
            }
        }