Created
October 19, 2015 05:01
-
-
Save rutcreate/617de73058fc7fb44a58 to your computer and use it in GitHub Desktop.
Unity3D: Example of post process build
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 UnityEditor; | |
using UnityEditor.Callbacks; | |
using System.Diagnostics; | |
using System.IO; | |
public static class ProcessBuild | |
{ | |
[PostProcessBuild(1000)] | |
public static void OnPostProcessBuild(BuildTarget target, string pathToBuiltProject) | |
{ | |
var process = new Process(); | |
process.StartInfo.FileName = "python2.6"; | |
process.StartInfo.Arguments = string.Format("{0}/Scripts/python_script.py {1}", Directory.GetCurrentDirectory(), pathToBuiltProject); | |
process.StartInfo.UseShellExecute = false; | |
process.StartInfo.RedirectStandardOutput = true; | |
process.StartInfo.RedirectStandardError = true; | |
process.Start(); | |
string err = process.StandardError.ReadToEnd(); | |
process.WaitForExit(); | |
if (process.ExitCode != 0) | |
{ | |
UnityEngine.Debug.LogError("error: " + err + " code: " + process.ExitCode); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment