You've already forked Commercialization.topon
更新sdk
This commit is contained in:
@@ -16,7 +16,7 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
|
||||
|
||||
public class ATConfig
|
||||
{
|
||||
public static string PLUGIN_VERSION = "2.1.5";
|
||||
public static string PLUGIN_VERSION = "2.1.7";
|
||||
public static bool isDebug = false;
|
||||
|
||||
public static int PLUGIN_TYPE = 1;
|
||||
@@ -46,36 +46,34 @@ public static bool isDebug = false;
|
||||
//network json文件名
|
||||
public static string network_data_file_name = "network_data.json";
|
||||
//插件设置的数据
|
||||
public static string plugin_setting_data_path = $"{RootPath}/Resources/json/" + PLUGIN_VERSION;
|
||||
public static string plugin_setting_data_file_name = "plugin_setting_data.json";
|
||||
public 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}/../../../";
|
||||
var scriptsPath = GetScriptsPath("ATConfig");
|
||||
_rootPath = string.IsNullOrEmpty(scriptsPath) ? "Assets/AnyThinkPlugin" : $"{scriptsPath}/../../../";
|
||||
}
|
||||
|
||||
return _rootPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static string GetScriptsPath (string scriptName)
|
||||
|
||||
public static string GetScriptsPath(string scriptName)
|
||||
{
|
||||
string[] path = UnityEditor.AssetDatabase.FindAssets(scriptName);
|
||||
if(path.Length >1)
|
||||
var guids = AssetDatabase.FindAssets($"{scriptName} t:Script");
|
||||
if (guids.Length != 1)
|
||||
{
|
||||
// Debug.LogError("有同名文件"+_scriptName+"获取路径失败");
|
||||
return null;
|
||||
}
|
||||
//将字符串中得脚本名字和后缀统统去除掉
|
||||
string _path = AssetDatabase.GUIDToAssetPath(path[0]).Replace((@"/" +scriptName +".cs"),"");
|
||||
return _path;
|
||||
|
||||
return AssetDatabase.GUIDToAssetPath(guids[0]).Replace("/" + scriptName + ".cs", "");
|
||||
}
|
||||
|
||||
//保存插件设置的数据,保存时机:安装core包、选择国家、切换SDK、androidX设置发生变化时
|
||||
@@ -157,6 +155,23 @@ public static bool isDebug = false;
|
||||
FileUtil.DeleteFileOrDirectory(path + ".meta");
|
||||
}
|
||||
}
|
||||
//针对mintegral改名字为gtm后,旧版升级到新版,旧版的mintegral目录需要删除
|
||||
var displayName = network.DisplayName;
|
||||
var name = network.Name;
|
||||
ATLog.log("removeInstalledNetwork() >>> displayName: " + displayName + " name: " + name);
|
||||
if (Equals(displayName, "Mintegral") && Equals(name, "Gtm"))
|
||||
{
|
||||
displayName = "mintegral";
|
||||
var mtgPath = getNetworkInstallPath(displayName, os, network.Country);
|
||||
if (Directory.Exists(mtgPath))
|
||||
{
|
||||
FileUtil.DeleteFileOrDirectory(mtgPath);
|
||||
if (File.Exists(mtgPath + ".meta"))
|
||||
{
|
||||
FileUtil.DeleteFileOrDirectory(mtgPath + ".meta");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -275,10 +290,22 @@ public static bool isDebug = false;
|
||||
return country == CHINA_COUNTRY ? IOS_NETWORK_FILES_PARENT_PATH + networkName : NONCHINA_IOS_NETWORK_FILES_PARENT_PATH + networkName;
|
||||
}
|
||||
|
||||
//根据network名字去获取安装路径
|
||||
private static string getNetworkInstallPath(string networkName, int os, int country)
|
||||
{
|
||||
if (os == OS_ANDROID) {
|
||||
return country == CHINA_COUNTRY ? CHINA_ANDROID_NETWORK_FILES_PARENT_PATH + networkName.ToLower() : NONCHINA_ANDROID_NETWORK_FILES_PARENT_PATH + networkName.ToLower();
|
||||
} else {
|
||||
return country == CHINA_COUNTRY ? IOS_NETWORK_FILES_PARENT_PATH + networkName : NONCHINA_IOS_NETWORK_FILES_PARENT_PATH + networkName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static int getSelectedCountry() {
|
||||
public static int getSelectedCountry()
|
||||
{
|
||||
var pluginSettingData = getPluginSettingData();
|
||||
if (pluginSettingData != null) {
|
||||
if (pluginSettingData != null)
|
||||
{
|
||||
return pluginSettingData.curCountry;
|
||||
}
|
||||
return CHINA_COUNTRY;
|
||||
@@ -387,7 +414,8 @@ public static bool isDebug = false;
|
||||
if(PLUGIN_TYPE == 2) {
|
||||
return new string[] { "Overseas" };
|
||||
}
|
||||
return new string[] { "ChinaMainland", "Overseas" };
|
||||
// return new string[] { "ChinaMainland", "Overseas" };
|
||||
return new string[] { "ChinaMainland" };
|
||||
}
|
||||
|
||||
public static string getRegionIntegrateTip()
|
||||
@@ -423,4 +451,4 @@ public static bool isDebug = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,10 +156,10 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
|
||||
private static IEnumerable<ServerNetworkInfo> GetUniqueNetworkInfo(ServerNetworkInfo[] androidNetworks, ServerNetworkInfo[] iosNetworks)
|
||||
{
|
||||
// Android独有的
|
||||
var uniqueToAndroid = androidNetworks.Where(a => !iosNetworks.Any(i => i.name == a.name));
|
||||
var uniqueToAndroid = androidNetworks.Where(a => !iosNetworks.Any(i => i.displayName == a.displayName));
|
||||
|
||||
// iOS独有的
|
||||
var uniqueToIos = iosNetworks.Where(i => !androidNetworks.Any(a => a.name == i.name));
|
||||
var uniqueToIos = iosNetworks.Where(i => !androidNetworks.Any(a => a.displayName == i.displayName));
|
||||
|
||||
// 合并结果
|
||||
return uniqueToAndroid.Concat(uniqueToIos);
|
||||
@@ -201,7 +201,7 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
|
||||
//合并相同的network
|
||||
for (int j = 0; j < min_length; j++) {
|
||||
var jNetwork = internalNetworks[j];
|
||||
if (Equals(iNetwork.name, jNetwork.name)) {
|
||||
if (Equals(iNetwork.displayName, jNetwork.displayName)) {
|
||||
network = flatServerNetwork(iNetwork, network);
|
||||
network = flatServerNetwork(jNetwork, network);
|
||||
networkList.Add(network);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 435df1e40057948a581aaa9c703eadba
|
||||
guid: 06d48237d6b6443f1b7cb368fc134467
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
|
||||
{
|
||||
public class AnyThinkMenuItems : MonoBehaviour
|
||||
{
|
||||
#if AnyThinkSDKEditor
|
||||
/**
|
||||
* The special characters at the end represent a shortcut for this action.
|
||||
*
|
||||
@@ -34,6 +33,5 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
|
||||
// }
|
||||
Application.OpenURL("https://newdocs.toponad.com/docs/lgfbO4");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using AnyThink.Scripts.IntegrationManager.Editor;
|
||||
using UnityEngine;
|
||||
// #if UNITY_EDITOR //是Unity编辑器才引入
|
||||
using UnityEditor;
|
||||
@@ -21,16 +22,93 @@ public class ATSdkUtil
|
||||
/// <returns>The exported path of the MAX plugin asset or the default export path if the asset is not found.</returns>
|
||||
public static string GetAssetPathForExportPath(string exportPath)
|
||||
{
|
||||
var defaultPath = Path.Combine("Assets", exportPath);
|
||||
var assetLabelToFind = "l:al_max_export_path-" + exportPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
|
||||
var normalizedExportPath = NormalizeAssetPath(exportPath);
|
||||
var defaultPath = NormalizeAssetPath(Path.Combine("Assets", normalizedExportPath));
|
||||
var assetLabelToFind = "l:al_max_export_path-" + normalizedExportPath;
|
||||
var assetGuids = AssetDatabase.FindAssets(assetLabelToFind);
|
||||
|
||||
return assetGuids.Length < 1 ? defaultPath : AssetDatabase.GUIDToAssetPath(assetGuids[0]);
|
||||
if (assetGuids.Length > 0)
|
||||
{
|
||||
var assetPath = AssetDatabase.GUIDToAssetPath(assetGuids[0]);
|
||||
if (!string.IsNullOrEmpty(assetPath))
|
||||
{
|
||||
return assetPath;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var candidatePath in GetCandidateAssetPaths(normalizedExportPath))
|
||||
{
|
||||
if (AssetExists(candidatePath))
|
||||
{
|
||||
return candidatePath;
|
||||
}
|
||||
}
|
||||
|
||||
var assetName = Path.GetFileNameWithoutExtension(normalizedExportPath);
|
||||
if (!string.IsNullOrEmpty(assetName))
|
||||
{
|
||||
var expectedSuffixes = new[]
|
||||
{
|
||||
normalizedExportPath,
|
||||
GetPluginRelativeExportPath(normalizedExportPath)
|
||||
};
|
||||
|
||||
foreach (var guid in AssetDatabase.FindAssets(assetName))
|
||||
{
|
||||
var assetPath = NormalizeAssetPath(AssetDatabase.GUIDToAssetPath(guid));
|
||||
if (expectedSuffixes.Any(suffix =>
|
||||
!string.IsNullOrEmpty(suffix) &&
|
||||
assetPath.EndsWith(suffix, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
return assetPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return defaultPath;
|
||||
}
|
||||
|
||||
public static bool Exists(string filePath)
|
||||
{
|
||||
return Directory.Exists(filePath) || File.Exists(filePath);
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetCandidateAssetPaths(string normalizedExportPath)
|
||||
{
|
||||
var pluginRelativeExportPath = GetPluginRelativeExportPath(normalizedExportPath);
|
||||
var dynamicRootPath = NormalizeAssetPath(ATConfig.RootPath);
|
||||
|
||||
if (!string.IsNullOrEmpty(dynamicRootPath))
|
||||
{
|
||||
yield return NormalizeAssetPath(Path.Combine(dynamicRootPath, pluginRelativeExportPath));
|
||||
}
|
||||
|
||||
yield return NormalizeAssetPath(Path.Combine("Assets", normalizedExportPath));
|
||||
}
|
||||
|
||||
private static string GetPluginRelativeExportPath(string normalizedExportPath)
|
||||
{
|
||||
const string pluginRootName = "AnyThinkPlugin/";
|
||||
return normalizedExportPath.StartsWith(pluginRootName, StringComparison.OrdinalIgnoreCase)
|
||||
? normalizedExportPath.Substring(pluginRootName.Length)
|
||||
: normalizedExportPath;
|
||||
}
|
||||
|
||||
private static string NormalizeAssetPath(string assetPath)
|
||||
{
|
||||
return string.IsNullOrEmpty(assetPath)
|
||||
? string.Empty
|
||||
: assetPath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).TrimStart(Path.AltDirectorySeparatorChar);
|
||||
}
|
||||
|
||||
private static bool AssetExists(string assetPath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(assetPath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(assetPath) != null || File.Exists(assetPath);
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user