Here is a build script to copy Icon.png and Default.png

This script copies the icon and splash screen every time the project is built.

  1. Create a file called PostprocessBuildPlayer in the Assets\Editor directory. Create the Editor directory if it does not already exist.

  2. Paste the code below into the file and save.

  3. Files to be copied should be in your project’s root directory. This is the directory that contains the Assets folder. Icon.png is the icon. Default.png is the start up screen.

  4. You can not replace the splash screen (Default.png) in the basic version on Unity iPhone so comment out the last 3 lines by putting a # at the beginning of each line.

Thank you so much, you just saved me an hour or so cursing at my computer (I’m not really into php and such).

gr.jakko

What should be the file extension? I’m not familiar with this script. :frowning:

Can I use it in Basic version? or it will work for only Pro version?

Kenlem, thanks!

I have the iPhone Pro version of Unity.

I can’t wait to try this, I am pretty close to release with a lite version of my game and would love to change the Unity splash screen logo to my own.

I’m gonna guess at .perl and test it.

[edit]
okay that didn’t work - I am trying .pl now as the extension I will build and run that to see if that works now.

[edit 2]
no that doesn’t do it either - sigh - The original unity “Default.png” always appears in the build and the iphone!

No file extension is needed.

This does not work for the basic version of Unity. The default screen can not be replaced in the basic version of Unity. Comment out the last 3 lines of the script by putting # at the beginning of each line.

Ok I will try without the file extension.

I have the Advanced Unity iPhone so hopefully its just the filename - I shall check and report back.

[edit]
No - that didn’t crack it either - I have followed the instructions very carefully but I must have missed something. Neither the icon.png or the default.png are being changed so I think Unity is not post processing the script you wrote for some reason.

I cut a paste the code you gave us, into a new file called “PostprocessBuildPlayer”, made a folder in my Project Assets folder called “Editor” and saved that file into it.

When I Build and Run my project Unity does some stuff and when xCode pops onto screen, I can immediately see that the default png is the Unity one. Not my new shiny new one. :frowning:

Any ideas please?

First of all, make sure your filenames are correct.

Icon.png
Default.png

Second, open up the log file after a build and see what results your getting after the script runs.

Window\Console then click the Show Editor Console Log button.

At the bottom, you should see something like:

Executing PostprocessBuildPlayer…

Make sure the script is being called and look for error messages.

kenlem,

Thanks for taking the time - here is a gif of my directory structure:

The red arrows are pointing at the graphics I want to be swapped into the xcode project. You can see the names are correct and I think they are in the correct place in the structure.

BTW IGNORE the old *.perl script that is not the one I have in the Editor folder inside the Assets folder, it now has no file extension on it.

The “Slippy Feet” folder structure which is highlighted in grey shows the resultant Unity/Xcode project ready to install… with the wrong default.png and icon.png in place.

I will check out the logs now.

no the logs just show this:

I have no idea where the *.perl file has come from in this log… I deleted it a lot earlier today and replaced it again with this *.pl one as that at least seemed to get some kind of note in the log, where the other one (with no extension) was not mentioned. I also keep clearing the logs to make sure I only see what has happened just now.

It is picking up something in your Assets/Editor directory. Make sure there is only the one file with no extension in there.

kenlem,

ok I will try that - I will remove the extension again.

[edit]
HOOORAY! Thanks for sticking with me - I used apple info to look at the file and remove the extension and that finally did the trick.

Thank you so much! :slight_smile:
[/edit]

This script is a boon! Thanks a lot. My other pet peeve is having to set the BundleDisplayName after every build, so I clumsily modified your script to do that. I’m not a Perl guy, so this could probably be done more succintly:

#!/usr/bin/perl
use File::Copy;

my $installPath = $ARGV[0];

#the name that displays on the iPhone
my $bundleDisplayName = "New App";

#copy Default.png and Icon.png from Asset to installPath
my $iconFilename = "Icon.png";
my $defaultFilename = "Default.png";

#go through the info.plist file line by line until you find this one:
my $findLine = "CFBundleDisplayName";

# The type of player built:
# "dashboard", "standaloneWin32", "standaloneOSXIntel", "standaloneOSXPPC", "standaloneOSXUniversal", "webplayer", "iPhone"
my $target = $ARGV[1];

print ("\n*** PostprocessBuildPlayer - Building at '$installPath' with target: $target ***\n");

my $dst = $installPath . "/" . $iconFilename;
print ("Copying Icon.png [$iconFilename -> $dst]\n");
copy($iconFilename, $dst) or die "Icon file can not be copied ";

my $dst = $installPath . "/" . $defaultFilename;
print ("Copying Default.png [$defaultFilename -> $dst]\n");
copy($defaultFilename, $dst) or die "Default file can not be copied "; 

#########
# This modifies info.plist so you don't have to
# set BundleDisplayName manually
#########

#open this file 
my $infile = $installPath . "/Info.plist";   
my $nextLine = 0;   
my $modFile = "";

open(IN,$infile) 
   || die "cannot open input file";
   
while(<IN>)
{ 	
	if ($nextLine == 1)
	{
		s/\${PRODUCT_NAME}/$bundleDisplayName/; #swap the product name for display name
	
		$nextLine = 0;
	}

	if (m/$findLine/)
	{
		$nextLine = 1;
	}
	
	$modFile .= $_;
}
close(IN);

open(OUT,">".$infile) 
   || die "cannot open output file";

print OUT $modFile; 

close(OUT);

It goes through Info.plist and swaps out ${PRODUCT_NAME} for bundleDisplayName on the line after it finds "CFBundleDisplayName". I did it this way because globally replacing {PRODUCT_NAME} might be undesirable.

I’ve successfully tested it locally.

p.s. I’d love it if the Bundle Display Name was one of the properties I could set in the Player Settings dialog (If any UT folks are reading).

Sweet!

I am getting the error:

0.0  kb    0.0% Assets/Scripts/Player/BoneInfo.js
Executing PostprocessBuildPlayer...
Could not launch /usr/bin/chmod.Could not launch /Users/Casey/MyProject/Assets/Editor/PostprocessBuildPlayer.

Any ideas?
I have pro, I created the script, it has no extension, sitting in the correct directory.

Very nice…thanks!

I am getting the same error… Have you found the reason?

I am getting a different error:

It can’t find the “use” command, i think. Any insight?

Here’s a small mod that changes the default profiler and FPS values. Where $toPath would be whatever $ARGV[0] is assigned to

################################################################
# Change default Profiler  kFPS rates                         #
################################################################

$oacmPath = $toPath."/Classes/AppController.mm";
$nacmPath = $toPath."/Classes/AppController.mm.tmp";

open OLDACM, "<", $oacmPath or die("Cannot open AppController.mm");
open NEWACM, ">", $nacmPath or die("Cannot create new AppController.mm");

while([list=1])
{
	if ($_ =~ m/ENABLE_INTERNAL_PROFILER/)
	{
		$_ =~ s/0/1/;
	}
	if ($_ =~ m/kFPS/)
	{
		$_ =~ s/60.0/30.0/;
	}
	if ($_ =~ m/kAccelerometerFrequency/)
	{
		$_ =~ s/60.0/30.0/;
	}
	print NEWACM $_;
}

close OLDACM;
close NEWACM;

`mv \'$nacmPath\' \'$oacmPath\'`;

Would it be possible for this script to add a key or two to the Info.plist file? Normally I would just make a version of Info.plist that has the keys I want, but one of my projects is being shared with another developer and we have different identifiers.

The two keys I add are:

UIPrerenderedIcon = true
UIInterfaceOrientation = UIInterfaceOrientationLandscapeRight

The first key removes the shine from the icon and the second one forces incoming text messages to be oriented sideways.

Here’s the script with flags you can set for prerendered icon and landscape orientation. I also added in zibba’s change which lets you adjust the kFPS and kAccelerometerFrequency.

I changed my file opening code to match zibba’s because it’s more consistent and readable.

If anyone from UT is watching, all these things should really be parameters in the project player settings.

This also might be something useful to add to the wiki (don’t know where).

#!/usr/bin/perl
use File::Copy;

my $installPath = $ARGV[0];

#the name that displays on the iPhone
my $bundleDisplayName = "New App";
# prerendered icons don't have the glossy effect applied over them.
my $prerenderedIcon = 1;
# determines orientation of OS popups (text messages, volume controls)
my $landscapeOrientation = 0;

# these three are values defined in AppController.m
my $fpsRate = "60.0";
my $accelerometerRate = "60.0";
my $profilerOn = "0";

#go through the info.plist file line by line until you find this one:
my $findLine = "CFBundleDisplayName";
my $endOfPlist = "</dict>";

#copy Default.png and Icon.png from Asset to installPath
my $iconFilename = "Icon.png";
my $defaultFilename = "Default.png";

# The type of player built:
# "dashboard", "standaloneWin32", "standaloneOSXIntel", "standaloneOSXPPC", "standaloneOSXUniversal", "webplayer", "iPhone"
my $target = $ARGV[1];

print ("\n*** PostprocessBuildPlayer - Building at '$installPath' with target: $target ***\n");

my $dst = $installPath . "/" . $iconFilename;
print ("Copying Icon.png [$iconFilename -> $dst]\n");
copy($iconFilename, $dst) or die "Icon file can not be copied ";

my $dst = $installPath . "/" . $defaultFilename;
print ("Copying Default.png [$defaultFilename -> $dst]\n");
copy($defaultFilename, $dst) or die "Default file can not be copied "; 

################################################################ 
# This modifies info.plist so you don't have to                #
# set BundleDisplayName manually                               #
################################################################ 

#open this file 

$oplistPath = $installPath."/Info.plist"; 
$nplistPath = $installPath."/Info.plist.tmp"; 

open OLDPLIST, "<", $oplistPath or die("Cannot open Info.plist"); 
open NEWPLIST, ">", $nplistPath or die("Cannot create new Info.plist"); 

my $nextLine = 0;   
   
while([list=1])
{ 	
	if ($nextLine == 1)
	{
		$_ =~ s/\${PRODUCT_NAME}/$bundleDisplayName/; #swap the product name for display name
	
		$nextLine = 0;
	}

	if ($_ =~ m/$findLine/)
	{
		$nextLine = 1;
	}
	
	################################################################ 
	# Add any key/value pairs you want at the end of Info.plist    #
	################################################################ 

	if ($_ =~ m/$endOfPlist/)
	{
		my $keys = "";
		
		if ($prerenderedIcon)
		{
			$keys .= "	<key>UIPrerenderedIcon</key>\n";
			$keys .= "	<true/>\n";
		}
		
		if ($landscapeOrientation)
		{
			$keys .= "	<key>UIInterfaceOrientation</key>\n";
			$keys .= "	<string>UIInterfaceOrientationLandscapeRight</string>\n";		
		}
		
		$_ = $keys . $_;
	}
	
	print NEWPLIST $_; 
}

close OLDPLIST; 
close NEWPLIST; 

`mv \'$nplistPath\' \'$oplistPath\'`; 

################################################################ 
# Change default Profiler  kFPS rates                         # 
################################################################ 

$oacmPath = $installPath."/Classes/AppController.mm"; 
$nacmPath = $installPath."/Classes/AppController.mm.tmp"; 

open OLDACM, "<", $oacmPath or die("Cannot open AppController.mm"); 
open NEWACM, ">", $nacmPath or die("Cannot create new AppController.mm"); 

while([list=1]) 
{ 
   if ($_ =~ m/ENABLE_INTERNAL_PROFILER/) 
   { 
      $_ =~ s/0/$profilerOn/; 
   } 
   if ($_ =~ m/kFPS/) 
   { 
      $_ =~ s/60.0/$fpsRate/; 
   } 
   if ($_ =~ m/kAccelerometerFrequency/) 
   { 
      $_ =~ s/60.0/$accelerometerRate/; 
   } 
   print NEWACM $_; 
} 

close OLDACM; 
close NEWACM; 

`mv \'$nacmPath\' \'$oacmPath\'`;