diff --git a/AnyThinkPlugin/Script/IntegrationManager/Editor/ATConfig.cs b/AnyThinkPlugin/Script/IntegrationManager/Editor/ATConfig.cs index 6ead263..5ee984e 100644 --- a/AnyThinkPlugin/Script/IntegrationManager/Editor/ATConfig.cs +++ b/AnyThinkPlugin/Script/IntegrationManager/Editor/ATConfig.cs @@ -23,7 +23,7 @@ public static bool isDebug = false; public static int OS_IOS = 2; public static int CHINA_COUNTRY = 1; public static int NONCHINA_COUNTRY = 2; - public static string ANYTHINK_SDK_FILES_PATH = "Assets/AnyThinkPlugin/AnyThinkAds"; + public static string ANYTHINK_SDK_FILES_PATH = $"{RootPath}/AnyThinkAds"; //国内Android core包的相关目录 public static string[] CHINA_ANDROID_CORE_FILES_ARRAY = {Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/Android/China/Editor"), Path.Combine(ANYTHINK_SDK_FILES_PATH, "Plugins/Android/China/anythink_base"), @@ -45,9 +45,38 @@ public static bool isDebug = false; //network json文件名 public static string network_data_file_name = "network_data.json"; //插件设置的数据 - private static string plugin_setting_data_path = "Assets/AnyThinkPlugin/Resources/json/" + PLUGIN_VERSION; + private static string plugin_setting_data_path = $"{RootPath}/Resources/json/" + PLUGIN_VERSION; private static string plugin_setting_data_file_name = "plugin_setting_data.json"; + private static string _rootPath; + + public static string RootPath + { + get + { + if (string.IsNullOrEmpty(_rootPath)) + { + var scriptsPath = GetScriptsPath ("ATConfig"); + _rootPath = $"{scriptsPath}/../../../"; + } + return _rootPath; + } + } + + + public static string GetScriptsPath (string scriptName) + { + string[] path = UnityEditor.AssetDatabase.FindAssets(scriptName); + if(path.Length >1) + { + // Debug.LogError("有同名文件"+_scriptName+"获取路径失败"); + return null; + } + //将字符串中得脚本名字和后缀统统去除掉 + string _path = AssetDatabase.GUIDToAssetPath(path[0]).Replace((@"/" +scriptName +".cs"),""); + return _path; + } + //保存插件设置的数据,保存时机:安装core包、选择国家、切换SDK、androidX设置发生变化时 public static void savePluginSettingData(PluginSettingData settingData) {