| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- 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.StandaloneModeOrPlatformB ? CommonConfig.AppNames[2]: CommonConfig.AppNames[0];
- #if UNITY_IOS
- PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, "com.xmjssvr.BowArrow");
- #endif
- #if UNITY_ANDROID
- if (CommonConfig.StandaloneModeOrPlatformB)
- {
- PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, "com.xmjssvr.BowArrow.miBClient"); //com.xmjssvr.BowArrow
- }
- else {
- PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, "com.xmjssvr.BowArrow.mi"); //com.xmjssvr.BowArrow
- }
- #endif
- SetIosAppIcon(0);
- }
- [MenuItem("APP语言版本切换/中文", true)]
- static bool ToCN_Check()
- {
- RefreshMenuChecked();
- return true;
- }
- [MenuItem("APP语言版本切换/英文")]
- static void ToEN()
- {
- //PlayerSettings.productName = CommonConfig.AppNames[1];
- PlayerSettings.productName = CommonConfig.StandaloneModeOrPlatformB ? CommonConfig.AppNames[2] : CommonConfig.AppNames[1];
- #if UNITY_IOS
- PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, "com.xmjssvr.BowArrowEn");
- #endif
- #if UNITY_ANDROID
- if (CommonConfig.StandaloneModeOrPlatformB)
- {
- PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, "com.xmjssvr.BowArrowEn.BClient"); //com.xmjssvr.BowArrow
- }
- else
- {
- PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, "com.xmjssvr.BowArrowEn");//com.xmjssvr.BowArrow.mi
- }
- #endif
- SetIosAppIcon(1);
- }
- [MenuItem("APP语言版本切换/英文", true)]
- static bool ToEN_Check()
- {
- RefreshMenuChecked();
- return true;
- }
- static void SetIosAppIcon(int id)
- {
- string path = "Assets/BowArrow/Textures/Common/AppIcon2.png";
- if (id == 1) {
- path = "Assets/BowArrow/Textures/Common/AppIconEN.png";
- }
- Texture2D texture = AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D)) as Texture2D;
- Texture2D[] textureArray = PlayerSettings.GetIconsForTargetGroup(BuildTargetGroup.Unknown);
- for (int i = 0; i < textureArray.Length; i++) textureArray[i] = texture;
- PlayerSettings.SetIconsForTargetGroup(BuildTargetGroup.Unknown, textureArray);
- AssetDatabase.SaveAssets();
- }
- }
|