| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using UnityEditor;
- using UnityEngine;
- //在编辑菜单中增加功能-APP语言版本切换
- public class MenuChangeAppLanguage
- {
- static void RefreshMenuChecked()
- {
- Menu.SetChecked("APP语言版本切换/中文", CommonConfig.AppLanguage == 0);
- Menu.SetChecked("APP语言版本切换/英文", CommonConfig.AppLanguage == 1);
- }
- [MenuItem("APP语言版本切换/中文")]
- static void ToCN()
- {
- 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");
- #endif
- }
- [MenuItem("APP语言版本切换/中文", true)]
- static bool ToCN_Check()
- {
- RefreshMenuChecked();
- return true;
- }
- [MenuItem("APP语言版本切换/英文")]
- static void ToEN()
- {
- 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");
- #endif
- }
- [MenuItem("APP语言版本切换/英文", true)]
- static bool ToEN_Check()
- {
- 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] = texture;
- PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.iOS, textureArray);
- AssetDatabase.SaveAssets();
- }
- }
|