| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 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");
- #endif
- #if UNITY_ANDROID
- 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];
- #if UNITY_IOS
- PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, "com.xmjssvr.BowArrowEn");
- #endif
- #if UNITY_ANDROID
- 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();
- }
- }
|