Table of contents
foreword
A special requirement requires configuring Android packaging related settings in the code.
1. Android signature setting relative path
This is relatively simple, find ProjectSettings.asset in the ProjectSettings file, one of the configurations is
AndroidKeystoreName: "E:/XXX/Moudle/Assets/Plugins/XXX.keystore"
modify it to
AndroidKeystoreName: ./Assets/Plugins/XXX.keystore
Check the settings to see that it has changed
2. Save the signature alias password
https://blog.csdn.net/acmhonor/article/details/94552089
I changed it after reading this post, so I won’t say more, thank you blogger.
3. Automatically set the startup screen
This part is a bit interesting, and it is realized by serializing and reading and writing the configuration in the ProjectSettings.asset file. Maybe everyone can’t use it, so there are relatively few materials. The link below has related usage, but it’s a bit wrong. I modified it.
https://answers.unity.com/questions/1619110/set-androids-static-splash-image-using-api.html
private static void ChangeImage()
{
string path = Application.dataPath + "/AllResources/Image/Logo/Start.png";
if (!File.Exists(path))
{
Debug.Log("文件不存在");
return;
}
Texture2D tex = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/AllResources/Image/Logo/Start.png");
const string projectSettings = "ProjectSettings/ProjectSettings.asset";
UnityEngine.Object obj = AssetDatabase.LoadAllAssetsAtPath(projectSettings)[0];
SerializedObject psObj = new SerializedObject(obj);
SerializedProperty androidSplashFileId = psObj.FindProperty("androidSplashScreen");
Debug.Log(androidSplashFileId);
if (androidSplashFileId != null)
{
androidSplashFileId.objectReferenceValue = tex;
}
psObj.ApplyModifiedProperties();
PlayerSettings.Android.splashScreenScale = AndroidSplashScreenScale.ScaleToFill;
}