Programmatically set default icon for mobile

Is there a way to do this?

I see PlayerSettings.SetIconsForTargetGroup()
but it would much easier to reset the default icon.

There doesn’t seem to be a way to set the splash screen either.

You can do this! Use this:

PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Unknown, theTexture2DArray);

Where theTexture2DArray is an array of the Texture2D asset you want to be the icon.

This will set the default icon from the player settings, and if there aren’t overrides for the platform icons, those will change also.

Hope this helps!

It would be great if Unity provided variables for these elements, but as it stands I don’t think you can change the icon in that way.

What we do is, say, have a folder named “Device/Icons” and “Device/Splash” where we have the icons and splash screen images. You can then drag these elements in the inspector to assign them as appropriate. You can then use the AssetDatabase.Copy command to overwrite these assets with other assets based on the particular build you are trying to create. For example, if you are using splash.png for your splash screen, you might do

AssetDatabase.CopyAsset("Assets/Christmas/Splash/splash.png", "Assets/Device/Splash/splash.png");

if you were creating a Christmas build. This doesn’t change the asset assigned in the inspector, but it effectively modifies the existing asset to change it.

EDIT: As mentioned in comments, this copy method could avoid some asset database confusion:

FileUtil.CopyFileOrDirectory("Assets/Christmas/Splash/splash.png", "Assets/Device/Splash/splash.png");

I don’t believe there is a way to change the default icon through script, but this is what i do.

Texture2D icon = Resources.Load(iconName) as Texture2D;
Texture2D[] icons = new Texture2D[]{icon, icon, icon, icon};

if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
    PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Android, icons);

However the FileUtil.CopyFileOrDirectory() log an error if the file already exists.
Also better the assets path to be absolute :

Here is what I do :

string _defaultPath = "/_MyAppFolder/Res/UI/_Common/Texture/Default_AppIcon.png";
string iconPath= "/_MyOtherAppFolder/Res/UI/_Common/Texture/OtherAppIcon.png";

FileUtil.DeleteFileOrDirectory(Application.dataPath + _defaultPath);
FileUtil.CopyFileOrDirectory(Application.dataPath + iconPath, Application.dataPath + _defaultPatht);