Unity Android's Testure reading format settings
Character models made for PC may be recognized incorrectly in the Android environment. The main reason is that the Texture format is incorrect.
The corresponding Ios actually has the same problem.
Solution
// An highlighted block
#if UNITY_ANDROID || UNITY_IOS
string path = AssetDatabase.GetAssetPath(Mesh);
AssetImporter asset = AssetImporter.GetAtPath(path);
TextureImporter textureImporter = asset as TextureImporter;
if (textureImporter != null)
{
SetTextureFormat(textureImporter);
textureImporter.SaveAndReimport();
}
AssetDatabase.Refresh();
#endif
// 修改格式
public static void SetTextureFormat(TextureImporter textureImporter)
{
textureImporter.isReadable = true;
#if UNITY_IOS
TextureImporterPlatformSettings ios = textureImporter.GetPlatformTextureSettings("iPhone");
ios.overridden = true;
ios.format = TextureImporterFormat.RGBAHalf;
textureImporter.SetPlatformTextureSettings(ios);
#elif UNITY_ANDROID
TextureImporterPlatformSettings android = textureImporter.GetPlatformTextureSettings("Android");
android.overridden = true;
android.format = TextureImporterFormat.RGBAHalf;
textureImporter.SetPlatformTextureSettings(android);
#endif
}
Note that
Android needs to modify ColorSpace
// 修改ColorSpace
#if UNITY_ANDROID
PlayerSettings.colorSpace = ColorSpace.Linear;
AssetDatabase.Refresh();
#endif
Regarding the specific reasons:
Original link