Browse Source

中英切换更新-ios图标

lvjincheng 2 years ago
parent
commit
f3e26cc01a
1 changed files with 17 additions and 0 deletions
  1. 17 0
      Assets/BowArrow/Scripts/Editor/MenuChangeAppLanguage.cs

+ 17 - 0
Assets/BowArrow/Scripts/Editor/MenuChangeAppLanguage.cs

@@ -1,4 +1,5 @@
 using UnityEditor;
+using UnityEngine;
 
 //在编辑菜单中增加功能-APP语言版本切换
 public class MenuChangeAppLanguage
@@ -15,6 +16,7 @@ public class MenuChangeAppLanguage
         PlayerSettings.productName = CommonConfig.AppNames[0];
         #if UNITY_IOS
         PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, "com.xmjssvr.BowArrow");
+        SetIosAppIcon(false);
         #endif
         #if UNITY_ANDROID
         PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, "com.xmjssvr.BowArrow.mi");
@@ -34,6 +36,7 @@ public class MenuChangeAppLanguage
         PlayerSettings.productName = CommonConfig.AppNames[1];
         #if UNITY_IOS
         PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, "com.xmjssvr.BowArrowEn");
+        SetIosAppIcon(true);
         #endif
         #if UNITY_ANDROID
         PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, "com.xmjssvr.BowArrowEn");
@@ -46,4 +49,18 @@ public class MenuChangeAppLanguage
         RefreshMenuChecked();
         return true;
     }
+
+    static void SetIosAppIcon(bool en)
+    {
+        Texture2D texture = null;
+        if (en) {
+            texture = AssetDatabase.LoadAssetAtPath(
+                "Assets/BowArrow/Textures/Common/AppIconEN.png", typeof(Texture2D)) as Texture2D;
+        }
+        int[] iconSize = PlayerSettings.GetIconSizesForTargetGroup(BuildTargetGroup.iOS);
+        Texture2D[] textureArray = new Texture2D[iconSize.Length];
+        for (int i = 0; i < textureArray.Length; i++) textureArray[i] = null;
+        PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.iOS, textureArray);
+        AssetDatabase.SaveAssets();
+    }
 }