Ok so I am looking through the PostprocessBuildPlayer stuff I can find and I see a lot of copying single files into the build directory but I am curious how I might copy a whole directory into a build folder? I know nothing about Perl so I don’t even know where to start but I am tired of copying my Documents folder and my database over after every build.
So while I see how I can copy my database over using the single file copy I still don’t see how to copy over a folder with an unknown amount of files in it.
Anyone have info of where I could start with this? Also, any good tutorials on how to write Perl that is applicable to Unity?
This is the code I am using to try to copy my Documents directory to the published folder … It does not seem to even run! how can I see if it runs or not? It is in Assets>Editor folder
#!/usr/bin/perl
use warnings;
use strict;
use Cwd;
use File::Copy;
use File::Glob 'bsd_glob';
use File::Basename qw(basename dirname fileparse);
########################################################################################################################
# #
# PostprocessBuildPlayer - v0.2 #
# #
# Revision History: #
# 2010-AUG-21 : Script v0.1 created by ZergCow #
# - Script written to be compatible with Unity 2.6 #
# #
########################################################################################################################
# Publish Arguments (Do not edit!) #####################################################################################
# Unity-Provided Publish Arguments
my $PublishFile = $ARGV[0]; # The published file (stand-alone, unityweb) path
my $PublishTarget = $ARGV[1]; # Publish output target (stand-alone, web player, etc.)
my $CompanyName = $ARGV[3]; # Company name as it appears under Edit > Project Settings > Player
my $ProductName = $ARGV[4]; # Product name as it appears under Edit > Project Settings > Player
my $DisplayWidth = $ARGV[5]; # The default display width as it appears under Edit > Project Settings > Player
my $DisplayHeight = $ARGV[6]; # The default display height as it appears under Edit > Project Settings > Player
# Parse the published web player file path into a file name, folder and suffix
my ($PublishFileName, $PublishFolder, $PublishSuffix) = fileparse($PublishFile, qr/\.[^.]*/);
# Publishing Options ##################################################################################################
# Publishing Options ##################################################################################################
#copy Default.png and Icon.png from Asset to installPath
my $dirFilename = "Documents";
print ("\n*** PostprocessBuildPlayer - Building at '$PublishFile' with target: $PublishTarget ***\n");
opendir(DIR, $dirFilename) or die "can't opendir $dirFilename: $! \n";
@files=readdir(DIR);
closedir DIR;
foreach $file (@files) {
if (-f "$dir$file") {
my $dst = $PublishFile . "/" . $dirFilename;
print ("Copying Icon.png [$iconFilename -> $dst\n");
copy($dirFilename, $dst) or die "Icon file can not be copied ";
}
}
########################################################################################################################
Just so that you know, the script doesn’t have to be written in Perl. You can use any executable file that can be run from the command line.
lol so Ii could write this in C# like I did for my Maya PostProcess script?
:roll:
I’d like to do the same thing (copy a folder to the build directory).
Would you mind sharing your script ? 
I never got this to work… Would be nice considering I have to manually copy paste my documents folder from the assets to the build every time I rebuild. I rebuild about 10 times a day… So yea I would love to see an example of this…
Does no one use a postprocess build player script? I would LOVE to see a working exmple or better yet, a tutorial. I can not seem to get this to work at all in any way.
Is there a build log where I can see if this script runs? Anything?
There is actually an example here on the Unity website. There are a couple of things that might be worth checking. Be sure that the name of the file is exactly PostprocessBuildPlayer (ie, without .txt or any other extension). Also, the file should be marked as executable, which is done using the chmod command on Unix systems like OSX.