You've already forked Commercialization.topon
更新sdk
This commit is contained in:
@@ -231,8 +231,8 @@ namespace AnyThink.Scripts.Editor
|
||||
{
|
||||
Directory.CreateDirectory(resXmlPath);
|
||||
}
|
||||
// var fromScriptableObject = MonoScript.FromScriptableObject(this);
|
||||
var xmlPath = GetScriptsPath("ATPostProcessBuildAndroid");
|
||||
|
||||
var xmlPath = GetScriptsPath("ATPostProcessBuildAndroid");
|
||||
saveFile($"{xmlPath}/anythink_network_security_config.xml", resXmlPath);
|
||||
}
|
||||
|
||||
@@ -243,17 +243,15 @@ namespace AnyThink.Scripts.Editor
|
||||
file.CopyTo(toFilesPath + "/" + newFileName, true);
|
||||
}
|
||||
|
||||
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", "");
|
||||
}
|
||||
|
||||
private static void addNetworkSecurityConfigInApplication(string path, bool isChina)
|
||||
@@ -341,4 +339,4 @@ namespace AnyThink.Scripts.Editor
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -104,6 +104,7 @@ namespace AnyThink.Scripts.Editor
|
||||
bunldePathsToAdd.Add(Path.Combine("Pods/", "BigoADS/BigoADS/BigoADSRes.bundle"));
|
||||
bunldePathsToAdd.Add(Path.Combine("Pods/", "Ads-Global/SDK/PAGAdSDK.bundle"));
|
||||
bunldePathsToAdd.Add(Path.Combine("Pods/", "Ads-CN/SDK/CSJAdSDK.bundle"));
|
||||
bunldePathsToAdd.Add(Path.Combine("Pods/", "Ads-CN-Beta/SDK/CSJAdSDK.bundle"));
|
||||
|
||||
return bunldePathsToAdd;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 88e0e347ecf5f4877b7026a0b60b5df0
|
||||
guid: 2e2b9e45df1464e4ca34d6674718bb2a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -279,6 +279,11 @@ namespace AnyThink.Scripts.Editor
|
||||
#else
|
||||
var buildGradlePath = Path.Combine(path, "launcher/build.gradle");
|
||||
#endif
|
||||
if (!File.Exists(buildGradlePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List<string> lines = new List<string>();
|
||||
bool isAdded = false;
|
||||
|
||||
@@ -296,7 +301,22 @@ namespace AnyThink.Scripts.Editor
|
||||
if (isAdded) {
|
||||
return;
|
||||
}
|
||||
using (StreamReader reader = new StreamReader("Assets/AnyThinkPlugin/Script/Editor/network_res_handle.gradle"))
|
||||
|
||||
var scriptDirectory = GetScriptsPath("ATProcessBuildGradleAndroid");
|
||||
if (string.IsNullOrEmpty(scriptDirectory))
|
||||
{
|
||||
ATLog.log("handleNetworkResMerge() >>> script directory not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
var networkResHandleGradlePath = Path.Combine(scriptDirectory, "network_res_handle.gradle");
|
||||
if (!File.Exists(networkResHandleGradlePath))
|
||||
{
|
||||
ATLog.log("handleNetworkResMerge() >>> gradle template missing: " + networkResHandleGradlePath);
|
||||
return;
|
||||
}
|
||||
|
||||
using (StreamReader reader = new StreamReader(networkResHandleGradlePath))
|
||||
{
|
||||
string line;
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
@@ -317,19 +337,34 @@ namespace AnyThink.Scripts.Editor
|
||||
// 设置你想要启动的Gradle任务
|
||||
string gradleTask = "handleNetworkResMerge"; // 例如: assembleDebug or assembleRelease
|
||||
|
||||
var gradleProjectRootPath = GetGradleProjectRootPath(path);
|
||||
if (!Directory.Exists(gradleProjectRootPath))
|
||||
{
|
||||
ATLog.log("callGradleTask() >>> gradle root not found: " + gradleProjectRootPath);
|
||||
return;
|
||||
}
|
||||
|
||||
var wrapperFileName = Application.platform == RuntimePlatform.WindowsEditor ? "gradlew.bat" : "gradlew";
|
||||
var gradleWrapperPath = Path.Combine(gradleProjectRootPath, wrapperFileName);
|
||||
if (!File.Exists(gradleWrapperPath))
|
||||
{
|
||||
ATLog.log("callGradleTask() >>> gradle wrapper missing: " + gradleWrapperPath);
|
||||
return;
|
||||
}
|
||||
|
||||
// 开始一个新的进程来执行Gradle任务
|
||||
ProcessStartInfo psi = new ProcessStartInfo();
|
||||
psi.FileName = Application.platform == RuntimePlatform.WindowsEditor ? "cmd" : "bash";
|
||||
psi.Arguments = Application.platform == RuntimePlatform.WindowsEditor ?
|
||||
$"/c gradlew {gradleTask}" : // Windows cmd命令
|
||||
$"-c './gradlew {gradleTask}'"; // UNIX bash命令
|
||||
$"/c \"{wrapperFileName} {gradleTask}\"" : // Windows cmd命令
|
||||
$"-c './{wrapperFileName} {gradleTask}'"; // UNIX bash命令
|
||||
psi.UseShellExecute = false;
|
||||
psi.StandardOutputEncoding = Encoding.UTF8;
|
||||
psi.StandardErrorEncoding = Encoding.UTF8;
|
||||
psi.RedirectStandardOutput = true;
|
||||
psi.RedirectStandardError = true;
|
||||
psi.CreateNoWindow = true;
|
||||
psi.WorkingDirectory = "/Users/quinx/Desktop/workspace_topon/sdk_source/a_unity_demo/TestAnyThinkUnityPlugin/Library/Bee/Android/Prj/Mono2x/Gradle"; // 这里应该是你的Android项目路径
|
||||
psi.WorkingDirectory = gradleProjectRootPath;
|
||||
|
||||
ATLog.log("callGradleTask() >>> path: " + path);
|
||||
|
||||
@@ -349,6 +384,26 @@ namespace AnyThink.Scripts.Editor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetGradleProjectRootPath(string path)
|
||||
{
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
return Path.GetFullPath(Path.Combine(path, ".."));
|
||||
#else
|
||||
return Path.GetFullPath(path);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static string GetScriptsPath(string scriptName)
|
||||
{
|
||||
var guids = AssetDatabase.FindAssets($"{scriptName} t:Script");
|
||||
if (guids.Length != 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return AssetDatabase.GUIDToAssetPath(guids[0]).Replace("/" + scriptName + ".cs", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -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