using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; using System; using System.IO; using System.Text; namespace Touka { public class ToukaEditor { static string assetPath = Application.dataPath; static string maxPath = assetPath + "/Plugins/ToukaGames/ADSSDK/MAXSDKs"; static string toponPath = assetPath + "/Plugins/ToukaGames/ADSSDK/ToponSDK"; static string maxPathX = assetPath + "/Plugins/ToukaGames/ADSSDK/MAXSDKs~"; static string toponPathX = assetPath + "/Plugins/ToukaGames/ADSSDK/ToponSDK~"; [MenuItem("ToukaGames/ClearPlayerPrefs", priority = 1)] public static void ClearPlayerPrefs() { PlayerPrefs.DeleteAll(); PlayerPrefs.Save(); } [MenuItem("ToukaGames/Settings For IOS CN", priority=1001)] public static void SetIOSCNTOPONSeting() { #if UNITY_IOS && !USE_U8 SetAPPSetting(AppChannel.AppStore_CN); #endif } [MenuItem("ToukaGames/Settings For Android CN", priority = 1002)] public static void SetAndroidCNSeting() { #if UNITY_ANDROID SetAPPSetting(AppChannel.GW002); #endif } [MenuItem("ToukaGames/Settings For IOS GB", priority = 10001)] public static void SetIOSUSSeting() { #if UNITY_IOS && !USE_U8 SetAPPSetting(AppChannel.AppStore_GB); #endif } [MenuItem("ToukaGames/Settings For Android GB", priority = 10002)] public static void SetAndroidGPSeting() { #if UNITY_ANDROID SetAPPSetting(AppChannel.GooglePlay); #endif } #region inner /// /// Set APP Setting /// /// public static void SetAPPSetting(AppChannel _appChannel) { Debug.Log("SetAPPSetting _appChannel : " + _appChannel); #if UNITY_IOS // bundle id if(_appChannel == AppChannel.AppStore_CN || _appChannel == AppChannel.AppStore_GB) { Debug.Log("SetAPPSetting 01 ----- _AppChannelSymbol : " + _appChannel); PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, TKGLoadConfig.GetConfigByKey(ConfigKeys.KEY_BunldId, _appChannel)); } #endif #if UNITY_ANDROID Debug.Log("SetAPPSetting 02 android ----- _AppChannelSymbol : " + _appChannel); PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, TKGLoadConfig.GetConfigByKey(ConfigKeys.KEY_BunldId, _appChannel)); #endif // game name PlayerSettings.productName = TKGLoadConfig.GetConfigByKey(ConfigKeys.KEY_AppName, _appChannel); Debug.Log("productName : " + PlayerSettings.productName); // ScriptingDefineSymbols & ads sdks ChangeDefineSymbols(_appChannel); } /// /// change define symbols /// /// private static void ChangeDefineSymbols(AppChannel _appChannel) { BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup; string symbolsStr = PlayerSettings.GetScriptingDefineSymbolsForGroup(buildTargetGroup); Debug.Log("symbolsStr : " + symbolsStr); string[] symbols = symbolsStr.Split(';'); HashSet symbolSet = new HashSet(); for (int i = 0; i < symbols.Length; ++i) { if (!symbolSet.Contains(symbols[i])) { symbolSet.Add(symbols[i]); } } // remove all if (symbolSet.Contains(AppChannel.AppStore_CN.ToString())) { symbolSet.Remove(AppChannel.AppStore_CN.ToString()); } if (symbolSet.Contains(AppChannel.AppStore_GB.ToString())) { symbolSet.Remove(AppChannel.AppStore_GB.ToString()); } if (symbolSet.Contains(AppChannel.GooglePlay.ToString())) { symbolSet.Remove(AppChannel.GooglePlay.ToString()); } if (symbolSet.Contains(AppChannel.GW002.ToString())) { symbolSet.Remove(AppChannel.GW002.ToString()); } // set new if (_appChannel == AppChannel.AppStore_GB || _appChannel == AppChannel.GooglePlay) { symbolSet.Add(_appChannel.ToString()); } // save data StringBuilder sb = new StringBuilder(); foreach (string s in symbolSet) { sb.Append(s + ";"); } PlayerSettings.SetScriptingDefineSymbolsForGroup(buildTargetGroup, sb.ToString()); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } /// /// SeIOSSDKDir /// /// private static void SeIOSSDKDir(AppChannel _AppChannelSymbol) { if (_AppChannelSymbol == AppChannel.AppStore_CN) // iOS CN { if (Directory.Exists(maxPath)) { ChangePathName(maxPath, maxPathX); } if (!Directory.Exists(toponPath)) { if (Directory.Exists(toponPathX)) { ChangePathName(toponPathX, toponPath); } } } else if (_AppChannelSymbol == AppChannel.AppStore_GB) // iOS GB { if (Directory.Exists(toponPath)) { ChangePathName(toponPath, toponPathX); } if (!Directory.Exists(maxPath)) { if (Directory.Exists(maxPathX)) { ChangePathName(maxPathX, maxPath); } } } else { TKGDebugger.LogDebug("other channel"); } } /// /// change path name /// /// /// private static void ChangePathName(string _oldPath, string _newPath) { System.IO.File.Move(_oldPath, _newPath); } #endregion } }