update core

This commit is contained in:
2023-09-04 16:57:46 +08:00
parent 0ff31be7c4
commit 6567d59019
394 changed files with 5659 additions and 7144 deletions

View File

@@ -0,0 +1,329 @@
#if UNITY_ANDROID && UNITY_2018_2_OR_NEWER
using AnyThink.Scripts.IntegrationManager.Editor;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using UnityEditor;
using UnityEditor.Android;
namespace AnyThink.Scripts.Editor
{
public class ATPostProcessBuildAndroid: IPostGenerateGradleAndroidProject
{
#if UNITY_2019_3_OR_NEWER
private static string PropertyAndroidX = "android.useAndroidX";
private static string PropertyJetifier = "android.enableJetifier";
private static string EnableProperty = "=true";
#endif
private static string PropertyDexingArtifactTransform = "android.enableDexingArtifactTransform";
private static string DisableProperty = "=false";
private static string KeyMetaDataAppLovinVerboseLoggingOn = "applovin.sdk.verbose_logging";
private static string KeyMetaDataGoogleApplicationId = "com.google.android.gms.ads.APPLICATION_ID";
private static string KeyMetaDataGoogleAdManagerApp = "com.google.android.gms.ads.AD_MANAGER_APP";
private static readonly XNamespace AndroidNamespace = "http://schemas.android.com/apk/res/android";
private static readonly XNamespace ToolsNamespace = "http://schemas.android.com/tools";
public void OnPostGenerateGradleAndroidProject(string path)
{
ATLog.log("OnPostGenerateGradleAndroidProject() >>> path: " + path);
#if UNITY_2019_3_OR_NEWER
var gradlePropertiesPath = Path.Combine(path, "../gradle.properties");
#else
var gradlePropertiesPath = Path.Combine(path, "gradle.properties");
#endif
processGradleProperties(gradlePropertiesPath);
processAndroidManifest(path);
processNetworkConfigXml(path);
ATProcessBuildGradleAndroid.processBuildGradle(path);
}
public int callbackOrder
{
get { return int.MaxValue; }
}
private static void processGradleProperties(string gradlePropertiesPath)
{
ATLog.log("OnPostGenerateGradleAndroidProject() >>> gradlePropertiesPath: " + gradlePropertiesPath + " File.Exists(gradlePropertiesPath): " + File.Exists(gradlePropertiesPath));
bool isChina = ATConfig.isSelectedChina();
var gradlePropertiesUpdated = new List<string>();
// If the gradle properties file already exists, make sure to add any previous properties.
if (File.Exists(gradlePropertiesPath))
{
var lines = File.ReadAllLines(gradlePropertiesPath);
#if UNITY_2019_3_OR_NEWER
// Add all properties except AndroidX, Jetifier, and DexingArtifactTransform since they may already exist. We will re-add them below.
gradlePropertiesUpdated.AddRange(lines.Where(line => !line.Contains(PropertyAndroidX) && !line.Contains(PropertyJetifier) && !line.Contains(PropertyDexingArtifactTransform)));
#else
// Add all properties except DexingArtifactTransform since it may already exist. We will re-add it below.
gradlePropertiesUpdated.AddRange(lines.Where(line => !line.Contains(PropertyDexingArtifactTransform)));
#endif
}
#if UNITY_2019_3_OR_NEWER
//如果是国内则根据选择来决定是否用AndroidX
if (isChina)
{
if (!ATPluginSetting.Instance.EnableAndroidX) {
EnableProperty = "=false";
} else {
EnableProperty = "=true";
}
} else {
EnableProperty = "=true";
}
ATLog.log("[AnyThink] AndroidX EnableProperty" + EnableProperty);
// Enable AndroidX and Jetifier properties
gradlePropertiesUpdated.Add(PropertyAndroidX + EnableProperty);
gradlePropertiesUpdated.Add(PropertyJetifier + EnableProperty);
#endif
// Disable dexing using artifact transform (it causes issues for ExoPlayer with Gradle plugin 3.5.0+)
gradlePropertiesUpdated.Add(PropertyDexingArtifactTransform + DisableProperty);
try
{
File.WriteAllText(gradlePropertiesPath, string.Join("\n", gradlePropertiesUpdated.ToArray()) + "\n");
}
catch (Exception exception)
{
ATLog.logError("Failed to enable AndroidX and Jetifier. gradle.properties file write failed.");
Console.WriteLine(exception);
}
}
private static void processAndroidManifest(string path)
{
#if UNITY_2019_3_OR_NEWER
var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml");
#else
var manifestPath = Path.Combine(path, "unityLibrary/src/main/AndroidManifest.xml");
#endif
// var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml");
XDocument manifest;
try
{
manifest = XDocument.Load(manifestPath);
}
#pragma warning disable 0168
catch (IOException exception)
#pragma warning restore 0168
{
ATLog.log("[AnyThink] AndroidManifest.xml is missing.");
return;
}
// Get the `manifest` element.
var elementManifest = manifest.Element("manifest");
if (elementManifest == null)
{
ATLog.log("[AnyThink] AndroidManifest.xml is invalid.");
return;
}
var elementApplication = elementManifest.Element("application");
if (elementApplication == null)
{
ATLog.log("[AnyThink] AndroidManifest.xml is invalid.");
return;
}
var metaDataElements = elementApplication.Descendants().Where(element => element.Name.LocalName.Equals("meta-data"));
addGoogleApplicationIdIfNeeded(elementApplication, metaDataElements);
// Save the updated manifest file.
manifest.Save(manifestPath);
}
private static void addGoogleApplicationIdIfNeeded(XElement elementApplication, IEnumerable<XElement> metaDataElements)
{
var googleApplicationIdMetaData = GetElementByName(metaDataElements, KeyMetaDataGoogleApplicationId);
if (!ATConfig.isAndroidNetworkInstalled("Admob", ATConfig.NONCHINA_COUNTRY))
{
ATLog.log("addGoogleApplicationIdIfNeeded() >>> Admob not install.");
if (googleApplicationIdMetaData != null) googleApplicationIdMetaData.Remove();
return;
}
var appId = ATPluginSetting.Instance.AdMobAndroidAppId;
// Log error if the App ID is not set.
if (string.IsNullOrEmpty(appId) || !appId.StartsWith("ca-app-pub-"))
{
ATLog.logError("AdMob App ID is not set. Please enter a valid app ID within the AnyThink Integration Manager window.");
return;
}
// Check if the Google App ID meta data already exists. Update if it already exists.
if (googleApplicationIdMetaData != null)
{
googleApplicationIdMetaData.SetAttributeValue(AndroidNamespace + "value", appId);
}
// Meta data doesn't exist, add it.
else
{
elementApplication.Add(CreateMetaDataElement(KeyMetaDataGoogleApplicationId, appId));
}
}
/// <summary>
/// Looks through all the given meta-data elements to check if the required one exists. Returns <c>null</c> if it doesn't exist.
/// </summary>
private static XElement GetElementByName(IEnumerable<XElement> elements, string name)
{
foreach (var element in elements)
{
var attributes = element.Attributes();
if (attributes.Any(attribute => attribute.Name.Namespace.Equals(AndroidNamespace)
&& attribute.Name.LocalName.Equals("name")
&& attribute.Value.Equals(name)))
{
return element;
}
}
return null;
}
/// <summary>
/// Creates and returns a <c>meta-data</c> element with the given name and value.
/// </summary>
private static XElement CreateMetaDataElement(string name, object value)
{
var metaData = new XElement("meta-data");
metaData.Add(new XAttribute(AndroidNamespace + "name", name));
metaData.Add(new XAttribute(AndroidNamespace + "value", value));
return metaData;
}
private static void processNetworkConfigXml(string path)
{
bool isChina = ATConfig.isSelectedChina();
// bool isChina = true;
//在application标签加上android:networkSecurityConfig="@xml/anythink_network_security_config"
addNetworkSecurityConfigInApplication(path, isChina);
#if UNITY_2019_3_OR_NEWER
var resXmlPath = Path.Combine(path, "src/main/res/xml");
#else
var resXmlPath = Path.Combine(path, "unityLibrary/src/main/res/xml");
#endif
var rexXmlDir = Path.Combine(resXmlPath, "anythink_network_security_config.xml");
if (File.Exists(rexXmlDir))
{
if (!isChina) //海外不用配置这个xml
{
FileUtil.DeleteFileOrDirectory(rexXmlDir);
}
return;
}
if (!Directory.Exists(resXmlPath))
{
Directory.CreateDirectory(resXmlPath);
}
saveFile("Assets/AnyThinkPlugin/Script/Editor/anythink_network_security_config.xml", resXmlPath);
}
public static void saveFile(string filePathName , string toFilesPath)
{
FileInfo file = new FileInfo(filePathName);
string newFileName= file.Name;
file.CopyTo(toFilesPath + "/" + newFileName, true);
}
private static void addNetworkSecurityConfigInApplication(string path, bool isChina)
{
#if UNITY_2019_3_OR_NEWER
var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml");
#else
var manifestPath = Path.Combine(path, "unityLibrary/src/main/AndroidManifest.xml");
#endif
// var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml");
XDocument manifest;
try
{
manifest = XDocument.Load(manifestPath);
}
#pragma warning disable 0168
catch (IOException exception)
#pragma warning restore 0168
{
ATLog.log("[AnyThink] AndroidManifest.xml is missing.");
return;
}
// Get the `manifest` element.
var elementManifest = manifest.Element("manifest");
if (elementManifest == null)
{
ATLog.log("[AnyThink] AndroidManifest.xml is invalid.");
return;
}
var elementApplication = elementManifest.Element("application");
if (elementApplication == null)
{
ATLog.log("[AnyThink] AndroidManifest.xml is invalid.");
return;
}
//handle anythink_network_security_config.xml
XAttribute networkConfigAttribute = elementApplication.Attribute(AndroidNamespace + "networkSecurityConfig");
if (networkConfigAttribute != null) {
networkConfigAttribute.Remove();
}
if (isChina)
{
elementApplication.Add(new XAttribute(AndroidNamespace + "networkSecurityConfig", "@xml/anythink_network_security_config"));
}
//这个设置主要是为了适配9.0以上的机器
//<uses-library android:name="org.apache.http.legacy" android:required="false" />
var usesLibraryElements = elementApplication.Descendants().Where(element => element.Name.LocalName.Equals("uses-library"));
if (usesLibraryElements == null)
{
elementApplication.Add(createHttpLegacyElement());
}
else
{
XElement httpLegacyElement = GetElementByName(usesLibraryElements, "org.apache.http.legacy");
if (httpLegacyElement == null)
{
elementApplication.Add(createHttpLegacyElement());
}
}
manifest.Save(manifestPath);
}
public static XElement createHttpLegacyElement()
{
var httpFeautre = new XElement("uses-library");
httpFeautre.Add(new XAttribute(AndroidNamespace + "name", "org.apache.http.legacy"));
httpFeautre.Add(new XAttribute(AndroidNamespace + "required", "false"));
return httpFeautre;
}
private static XElement CreateMetaDataElement(string name, object value, object toolsNode)
{
var metaData = new XElement("meta-data");
metaData.Add(new XAttribute(AndroidNamespace + "name", name));
metaData.Add(new XAttribute(AndroidNamespace + "value", value));
metaData.Add(new XAttribute(ToolsNamespace + "node", toolsNode));
return metaData;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: be367c330856340a4a9626db43b8917b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,187 @@
#if UNITY_IOS || UNITY_IPHONE
using AnyThink.Scripts.IntegrationManager.Editor;
#if UNITY_2019_3_OR_NEWER
using UnityEditor.iOS.Xcode.Extensions;
#endif
using UnityEngine.Networking;
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;
namespace AnyThink.Scripts.Editor
{
[Serializable]
public class SkAdNetworkData
{
[SerializeField] public string[] SkAdNetworkIds;
}
public class TopOnPostProcessBuildiOS
{
private static readonly List<string> AtsRequiringNetworks = new List<string>
{
"AdColony",
"ByteDance",
"Fyber",
"Google",
"GoogleAdManager",
"HyprMX",
"InMobi",
"IronSource",
"Smaato"
};
private static List<string> DynamicLibraryPathsToEmbed
{
get
{
var dynamicLibraryPathsToEmbed = new List<string>();
dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "KSAdSDK/KSAdSDK.xcframework"));
dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "StartAppSDK/StartApp.xcframework"));
dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "BigoADS/BigoADS/BigoADS.xcframework"));
dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "BigoADS/BigoADS/OMSDK_Bigosg.xcframework"));
dynamicLibraryPathsToEmbed.Add(Path.Combine("Pods/", "HyBid/PubnativeLite/PubnativeLite/OMSDK-1.3.29/OMSDK_Pubnativenet.xcframework"));
return dynamicLibraryPathsToEmbed;
}
}
private static List<string> BunldePathsToAdd {
get {
var bunldePathsToAdd = new List<string>();
bunldePathsToAdd.Add(Path.Combine("Pods/", "BigoADS/BigoADS/BigoADSRes.bundle"));
return bunldePathsToAdd;
}
}
private static readonly List<string> SwiftLanguageNetworks = new List<string>
{
"MoPub"
};
private static readonly List<string> EmbedSwiftStandardLibrariesNetworks = new List<string>
{
"Facebook",
"MoPub"
};
[PostProcessBuildAttribute(int.MaxValue)]
public static void TopOnPostProcessPbxProject(BuildTarget buildTarget, string buildPath)
{
var projectPath = PBXProject.GetPBXProjectPath(buildPath);
var project = new PBXProject();
project.ReadFromFile(projectPath);
#if UNITY_2019_3_OR_NEWER
var unityMainTargetGuid = project.GetUnityMainTargetGuid();
var unityFrameworkTargetGuid = project.GetUnityFrameworkTargetGuid();
#else
var unityMainTargetGuid = project.TargetGuidByName(UnityMainTargetName);
var unityFrameworkTargetGuid = project.TargetGuidByName(UnityMainTargetName);
#endif
project.SetBuildProperty(unityMainTargetGuid, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");
project.SetBuildProperty(unityMainTargetGuid, "ENABLE_BITCODE", "NO");
project.SetBuildProperty(unityFrameworkTargetGuid, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES");
project.SetBuildProperty(unityFrameworkTargetGuid, "ENABLE_BITCODE", "NO");
EmbedDynamicLibrariesIfNeeded(buildPath, project, unityMainTargetGuid);
AddBunleIfNeeded(buildPath, project, unityMainTargetGuid);
project.WriteToFile(projectPath);
}
[PostProcessBuildAttribute(int.MaxValue)]
public static void TopOnPostProcessPlist(BuildTarget buildTarget, string path)
{
var plistPath = Path.Combine(path, "Info.plist");
var plist = new PlistDocument();
plist.ReadFromFile(plistPath);
#if UNITY_2018_2_OR_NEWER
AddGoogleApplicationIdIfNeeded(plist);
#endif
plist.WriteToFile(plistPath);
}
private static void AddBunleIfNeeded(string buildPath, PBXProject project, string targetGuid)
{
var bunldePathsPresentInProject = BunldePathsToAdd.Where(bunldePath => Directory.Exists(Path.Combine(buildPath, bunldePath))).ToList();
if (bunldePathsPresentInProject.Count <= 0) return;
ATLog.log("AddBunleIfNeeded");
#if UNITY_2019_3_OR_NEWER
foreach (var bunldePath in bunldePathsPresentInProject)
{
var fileGuid = project.AddFile(bunldePath, bunldePath, PBXSourceTree.Source);
project.AddFileToBuild(targetGuid, fileGuid);
}
#endif
}
private static void EmbedDynamicLibrariesIfNeeded(string buildPath, PBXProject project, string targetGuid)
{
var dynamicLibraryPathsPresentInProject = DynamicLibraryPathsToEmbed.Where(dynamicLibraryPath => Directory.Exists(Path.Combine(buildPath, dynamicLibraryPath))).ToList();
if (dynamicLibraryPathsPresentInProject.Count <= 0) return;
#if UNITY_2019_3_OR_NEWER
foreach (var dynamicLibraryPath in dynamicLibraryPathsPresentInProject)
{
var fileGuid = project.AddFile(dynamicLibraryPath, dynamicLibraryPath);
project.AddFileToEmbedFrameworks(targetGuid, fileGuid);
}
#else
string runpathSearchPaths;
#if UNITY_2018_2_OR_NEWER
runpathSearchPaths = project.GetBuildPropertyForAnyConfig(targetGuid, "LD_RUNPATH_SEARCH_PATHS");
#else
runpathSearchPaths = "$(inherited)";
#endif
runpathSearchPaths += string.IsNullOrEmpty(runpathSearchPaths) ? "" : " ";
// Check if runtime search paths already contains the required search paths for dynamic libraries.
if (runpathSearchPaths.Contains("@executable_path/Frameworks")) return;
runpathSearchPaths += "@executable_path/Frameworks";
project.SetBuildProperty(targetGuid, "LD_RUNPATH_SEARCH_PATHS", runpathSearchPaths);
#endif
}
#if UNITY_2018_2_OR_NEWER
private static void AddGoogleApplicationIdIfNeeded(PlistDocument plist)
{
if (!ATConfig.isIOSNetworkInstalled("Admob", ATConfig.NONCHINA_COUNTRY))
{
ATLog.log("addGoogleApplicationIdIfNeeded() >>> Admob not install.");
return;
}
var appId = ATPluginSetting.Instance.AdMobIosAppId;
if (string.IsNullOrEmpty(appId) || !appId.StartsWith("ca-app-pub-"))
{
ATLog.logError("AdMob App ID is not set. Please enter a valid app ID within the AnyThink Integration Manager window.");
return;
}
const string googleApplicationIdentifier = "GADApplicationIdentifier";
plist.root.SetString(googleApplicationIdentifier, appId);
}
#endif
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2e2b9e45df1464e4ca34d6674718bb2a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,270 @@
#if UNITY_ANDROID && UNITY_2018_2_OR_NEWER
using AnyThink.Scripts.IntegrationManager.Editor;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using UnityEditor;
using UnityEditor.Android;
using System.Text.RegularExpressions;
namespace AnyThink.Scripts.Editor
{
public class ATProcessBuildGradleAndroid
{
// public void OnPostGenerateGradleAndroidProject(string path)
// {
// }
public static void processBuildGradle(string path)
{
#if UNITY_2019_3_OR_NEWER
var buildGradlePath = Path.Combine(path, "../build.gradle");
#else
var buildGradlePath = Path.Combine(path, "build.gradle");
#endif
#if UNITY_2022_1_OR_NEWER
ATLog.log("processBuildGradle() >>> called");
#else
replaceBuildPluginVersion(buildGradlePath);
// replaceAppBuildPluginVersion(path);
#endif
// replaceAppBuildPluginVersion(path);
handleNetworksConfit(path);
}
//修改项目的根目录下的build.gradle文件的插件版本号
private static void replaceBuildPluginVersion(string buildGradlePath)
{
if (!File.Exists(buildGradlePath))
{
return;
}
string gradleFileContent = "";
using (StreamReader reader = new StreamReader(buildGradlePath))
{
gradleFileContent = reader.ReadToEnd();
}
if (string.IsNullOrEmpty(gradleFileContent))
{
return;
}
string buildGradleVersion = "";
string buildGradlePattern = "";
string buildGradleVersion3 = "3.3.3"; // 新gradle插件版本号
string buildGradlePattern3 = @"(?<=gradle:)3\.3\.\d+";
string buildGradleVersion4 = "3.4.3";
string buildGradlePattern4 = @"(?<=gradle:)3\.4\.\d+";
string buildGradleVersion5 = "3.5.4";
string buildGradlePattern5 = @"(?<=gradle:)3\.5\.\d+";
string buildGradleVersion6 = "3.6.4";
string buildGradlePattern6 = @"(?<=gradle:)3\.6\.\d+";
if (isMatchGradleVersion(gradleFileContent, buildGradleVersion3))
{
buildGradleVersion = buildGradleVersion3;
buildGradlePattern = buildGradlePattern3;
}
else if(isMatchGradleVersion(gradleFileContent, buildGradleVersion4))
{
buildGradleVersion = buildGradleVersion4;
buildGradlePattern = buildGradlePattern4;
}
else if(isMatchGradleVersion(gradleFileContent, buildGradleVersion5))
{
buildGradleVersion = buildGradleVersion5;
buildGradlePattern = buildGradlePattern5;
}
else if(isMatchGradleVersion(gradleFileContent, buildGradleVersion6))
{
buildGradleVersion = buildGradleVersion6;
buildGradlePattern = buildGradlePattern6;
}
if (!string.IsNullOrEmpty(buildGradlePattern) && !string.IsNullOrEmpty(buildGradleVersion))
{
replaceContent(buildGradlePath, buildGradlePattern, buildGradleVersion);
}
}
private static void replaceContent(string filePath, string pattern, string content)
{
if (!File.Exists(filePath))
{
return;
}
string buildGradle = "";
using (StreamReader reader = new StreamReader(filePath))
{
buildGradle = reader.ReadToEnd();
}
// Regex regex = new Regex(pattern);
buildGradle = Regex.Replace(buildGradle, pattern, content);
// 修改gradle-wrapper版本号
// string oldWrapperVersion = "distributionUrl=https\\://services.gradle.org/d
using (StreamWriter writer = new StreamWriter(filePath))
{
writer.Write(buildGradle);
}
}
private static bool isMatchGradleVersion(string gradleFileContent, string version)
{
string matchStr = String.Format("gradle:{0}", version.Substring(0, 3));
return gradleFileContent.Contains(matchStr);
}
//修改app module下的build.gradle
private static void replaceAppBuildPluginVersion(string path)
{
#if UNITY_2019_3_OR_NEWER
var buildGradlePath = Path.Combine(path, "../launcher/build.gradle");
#else
var buildGradlePath = Path.Combine(path, "launcher/build.gradle");
#endif
if (!File.Exists(buildGradlePath))
{
return;
}
string buildGradleVersion = "30";
string compileSdkVersionPattern = "compileSdkVersion";
string targetSdkVersionPattern = "targetSdkVersion";
List<string> lines = new List<string>();
using (StreamReader reader = new StreamReader(buildGradlePath))
{
string line;
while ((line = reader.ReadLine()) != null)
{
lines.Add(line);
}
}
int indexToReplace = -1;
int indexToReplace1 = -1;
int removeIndex = -1;
int addIndex = -1;
for (int i = 0; i < lines.Count; i++)
{
if (lines[i].Contains(compileSdkVersionPattern))
{
indexToReplace = i;
}
else if (lines[i].Contains(targetSdkVersionPattern))
{
indexToReplace1 = i;
}
else if (lines[i].Contains("buildToolsVersion"))
{
removeIndex = i;
}
else if (lines[i].Contains("defaultConfig"))
{
addIndex = i;
}
}
if (indexToReplace != -1)
{
lines[indexToReplace] = " " + compileSdkVersionPattern + " " + buildGradleVersion;
}
if (indexToReplace1 != -1)
{
lines[indexToReplace1] = " " + targetSdkVersionPattern + " " + buildGradleVersion;
}
if (removeIndex != -1)
{
lines.RemoveAt(removeIndex);
}
if (addIndex != -1)
{
lines.Insert(addIndex + 1, " multiDexEnabled true");
}
using (StreamWriter writer = new StreamWriter(buildGradlePath))
{
foreach (string line in lines)
{
writer.WriteLine(line);
}
}
}
private static void handleNetworksConfit(string path)
{
if (ATConfig.isSelectedChina())
{
return;
}
#if UNITY_2019_3_OR_NEWER
var buildGradlePath = Path.Combine(path, "../launcher/build.gradle");
#else
var buildGradlePath = Path.Combine(path, "launcher/build.gradle");
#endif
if (!File.Exists(buildGradlePath))
{
return;
}
List<string> lines = new List<string>();
using (StreamReader reader = new StreamReader(buildGradlePath))
{
string line;
while ((line = reader.ReadLine()) != null)
{
lines.Add(line);
}
}
var androidStartIndex = 0;
var isConfigAll = false;
var isExcludeModule = false;
for (int i = 0; i < lines.Count; i++)
{
if (lines[i].Contains("android {"))
{
androidStartIndex = i;
}
else if (lines[i].Contains("configurations.all"))
{
isConfigAll = true;
}
else if (lines[i].Contains("META-INF/*.kotlin_module"))
{
isExcludeModule = true;
}
}
if (androidStartIndex > 0)
{
if (!isExcludeModule)
{
lines.Insert(androidStartIndex + 1, " packagingOptions {\n merge 'META-INF/com.android.tools/proguard/coroutines.pro'\n exclude 'META-INF/*.kotlin_module'\n }");
}
if (!isConfigAll)
{
lines.Insert(androidStartIndex -1, "configurations.all {\n resolutionStrategy {\n force 'androidx.core:core:1.6.0'\n force 'androidx.recyclerview:recyclerview:1.1.0' \n }\n}");
}
}
// configurations.all {
// resolutionStrategy {
// force 'androidx.core:core:1.6.0'
// force 'androidx.recyclerview:recyclerview:1.1.0'
// }
// }
// packagingOptions {
// merge "META-INF/com.android.tools/proguard/coroutines.pro"
// exclude "META-INF/*.kotlin_module"
// }
using (StreamWriter writer = new StreamWriter(buildGradlePath))
{
foreach (string line in lines)
{
writer.WriteLine(line);
}
}
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 311da97c47b0c4a21a96c7f310f9d8ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
{
"name": "AnyThinkPlugin.Script.Editor",
"references": [
"AnyThinkPlugin.Script",
"AnyThinkPlugin.Script.IntegrationManager.Editor"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": []
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fe7f15635ecfd4b0a9b59690ece5d0c6
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9d4c4072cdc0f40c0b81bc2dc3d2dac2
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: