Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raldred/b2100b5e8855c81cae2a6bbb278580bb to your computer and use it in GitHub Desktop.
Save raldred/b2100b5e8855c81cae2a6bbb278580bb to your computer and use it in GitHub Desktop.
Unity 5.3 PostprocessBuildPlayer Trigger Replacement
using System;
using System.IO;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
public class ReplacementBuildPostprocessor : MonoBehaviour
{
[PostProcessBuildAttribute(-1000)]
public static void OnPostprocessBuild(BuildTarget target, string pathToBuild)
{
UnityEngine.Debug.Log("Beginning postprocess: "+pathToBuild);
string player = target.ToString() == "iOS" ? "iPhone" : target.ToString();
string arguments = String.Format("\"{0}\" \"{1}\" \"{2}\" \"{3}\" \"{4}\" \"{5}\" \"{6}\"", pathToBuild,
player, "", PlayerSettings.companyName, PlayerSettings.productName,
PlayerSettings.defaultScreenWidth, PlayerSettings.defaultScreenHeight);
UnityEngine.Debug.Log("Starting script: python " + Application.dataPath + "/Editor/PostprocessBuildPlayer" + " " + arguments);
Process process = new Process();
process.StartInfo.FileName = "python";
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.Arguments = "\"" + Application.dataPath + "/Editor/PostprocessBuildPlayer\"" + " " + arguments;
process.Start();
// Synchronously read the standard output of the spawned process.
StreamReader reader = process.StandardOutput;
string output = reader.ReadToEnd();
// Write the redirected output to this application's window.
Console.WriteLine(output);
process.WaitForExit();
process.Close();
UnityEngine.Debug.Log("Done postprocess");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment