Created
January 15, 2016 00:20
-
-
Save cojo/82c97da501529e44fb56 to your computer and use it in GitHub Desktop.
Unity 5.3 PostprocessBuildPlayer Trigger Replacement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: perl " + Application.dataPath + "/Editor/PostprocessBuildPlayer" + " " + arguments); | |
Process process = new Process(); | |
process.StartInfo.FileName = "perl"; | |
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fantastic. Might not matter, but the file from my legacy project was named PostProcessBuildPlayer (title case).