| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 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");
- PlayerSettings.iOS.appleDeveloperTeamID = "WR7WD35237";
- PlayerSettings.iOS.appleEnableAutomaticSigning = true;
- #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");
- PlayerSettings.iOS.appleDeveloperTeamID = "WR7WD35237";
- PlayerSettings.iOS.appleEnableAutomaticSigning = true;
- #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();
- }
- }
|