Skip to content

Instantly share code, notes, and snippets.

@rutcreate
Created October 19, 2015 05:01
Show Gist options
  • Save rutcreate/617de73058fc7fb44a58 to your computer and use it in GitHub Desktop.
Save rutcreate/617de73058fc7fb44a58 to your computer and use it in GitHub Desktop.
Unity3D: Example of post process build
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