Change Android splash screen background from script

How can I change Android splash screen background from script before build? I have 2 versions of my game and before I build them I need to change the splash screen accordingly to the game version.
I can change PlayerSettings.SplashScreen.background but it seems it does nothing. I don’t see a way to change static splash screen image for Android.

I’ll need to change it too on iOS and windows, is there a general solution to this problem?

There is no way to change the static splash screen image from the script. PlayerSettings.SplashScreen.background is for the animated / dynamic splash screen and should work if you use that type of splash screen in your project.

1.Read guid from meta file of texture

e.g.
fileFormatVersion: 2
guid: 083673308dc792f4c99f3d3e33b383f8
timeCreated: 1543575763

2.And replace it to guid in projectSettings

e.g.
Read file ProjectSettings.asset:

string projectSettingsPath = Application.dataPath.Replace(“/Assets”, “/ProjectSettings/ProjectSettings.asset”);
string projectSettings = File.ReadAllText(projectSettingsPath);

And Replace red marked text below with red marked text in step 1.

androidSplashScreen: {fileID: 2800000, guid: 8d7f092f78c6bcb429a60803a22bf208, type: 3}

How about this? I wrote this for iOS, it should be basically the same for Android.

static void ModifyIphoneAndIPadBackgroundColor(Color32 iphoneBg, Color32 ipadBg)
{
const string projectSettings = "ProjectSettings/ProjectSettings.asset";
UnityEngine.Object obj = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(projectSettings)[0];
SerializedObject psObj = new SerializedObject(obj);
SerializedProperty iPhoneBgColor = psObj.FindProperty ("iOSLaunchScreenBackgroundColor.rgba");
SerializedProperty iPadBgColor= psObj.FindProperty("iOSLaunchScreeniPadBackgroundColor.rgba");
UInt32 iphoneBgC = ((UInt32)iphoneBg.a) << 24 | ((UInt32)iphoneBg.b) << 16 | ((UInt32)iphoneBg.g) << 8 | ((UInt32)iphoneBg.r);
iPhoneBgColor.longValue = iphoneBgC;
UInt32 ipadBgC = ((UInt32)ipadBg.a) << 24 | ((UInt32)ipadBg.b) << 16 | ((UInt32)ipadBg.g) << 8 | ((UInt32)ipadBg.r);
iPadBgColor.longValue = ipadBgC;
psObj.ApplyModifiedProperties();
}

1 Like

it’s useful! I change Android’s static splash image successfully!

Texture2D tex = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Logo/logo_default.png");
const string projectSettings = "ProjectSettings/ProjectSettings.asset";
UnityEngine.Object obj = AssetDatabase.LoadAllAssetsAtPath(projectSettings)[0];
SerializedObject psObj = new SerializedObject(obj);
SerializedProperty androidSplashFileId = psObj.FindProperty("androidSplashScreen.m_FileID");
if (androidSplashFileId != null)
{
    androidSplashFileId.intValue = tex.GetInstanceID();
}
psObj.ApplyModifiedProperties();
1 Like

Do you know how to change the default icon as well? I am not able to find the Serialized property for the same.