RomaValcer
RomaValcer

Reputation: 2966

Execute a program/script during build

For instance, I have some documentation generator and I want Unity to generate fresh docs (execute it) after every compilation. How do I do this?

Upvotes: 0

Views: 955

Answers (1)

peterept
peterept

Reputation: 4427

You can use a post build script.

Unity will call any c# editor class method marked as PostProcessBuildAttribute.

Eg:

public class MyBuildPostprocessor {
    [PostProcessBuildAttribute(1)]
    public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject) {
        // Execute your external script here
        // Eg: ProcessStartInfo proc = new ProcessStartInfo();
        }
}

Or use the older (Mac only) PostprocessBuildPlayer shell script in your Editor folder which is also called at the end of the build.

Upvotes: 2

Related Questions