update 1.1.25

This commit is contained in:
2024-03-07 15:23:32 +08:00
parent c7873052f2
commit aa9954b91a
224 changed files with 923 additions and 337 deletions

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ecbff3e4ceb2645ec8bb940d0dde7174
guid: e1c2a723fcc7d4a5cad5c4b082740029
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -7,14 +7,15 @@ using System.Xml.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.Networking;
using AnyThink.Scripts.Assets;
using System.Text.RegularExpressions;
namespace AnyThink.Scripts.IntegrationManager.Editor
{
// public class ATConfig : ScriptableObject
public class ATConfig
{
public static string PLUGIN_VERSION = "2.0.1";
public static string PLUGIN_VERSION = "2.0.3";
public static bool isDebug = false;
private static string LAST_SELECT_COUNTRY_KEY = "country_key"; //国家
public static int CHINA_COUNTRY = 1;
@@ -30,6 +31,7 @@ public static bool isDebug = false;
//iOS network依赖文件的目录不区分国家
public static string IOS_NETWORK_FILES_PARENT_PATH = "Assets/AnyThinkAds/Plugins/iOS/";
// 保存已安装的network到本地
public static void saveInstalledNetworkVersion(string networkName, Versions v)
{
@@ -38,33 +40,73 @@ public static bool isDebug = false;
ATLog.log("saveInstalledNetworkVersion() >>> networkName: " + networkName + " unity: " + versions.Unity);
versions = initUnityForVerions(versions, networkName, country);
// ATPluginSetting.Instance.saveInstalledNetwork(networkName, country, versions);
string jsonStr = JsonUtility.ToJson(versions);
PlayerPrefs.SetString(networkName + "_" + country, jsonStr);
PlayerPrefs.Save();
string key = networkName + "_" + country;
// ATConfigAsset2.Instance.saveInstalledNetworkVersion(key, jsonStr);
PlayerPrefs.SetString(key, jsonStr);
}
//获取已安装的network版本包括core network
public static Versions getInstalledNetworkVersion(string networkName, int country)
{
Versions versions = null;
string sdkJson = string.Empty;
string key = networkName + "_" + country;
// sdkJson = ATConfigAsset2.Instance.getInstalledNetworkVersion(key);
sdkJson = PlayerPrefs.GetString(key);
ATLog.log("getInstalledNetworkVersion() >>> key: " + key + " sdkJson: " + sdkJson + " country: " + country);
if (sdkJson == null || sdkJson.Length == 0)
{
//适配旧版本插件避免直接升级SDK
// if (PlayerPrefs.HasKey(key)) {
// sdkJson = PlayerPrefs.GetString(key);
// PlayerPrefs.DeleteKey(key);
// } else {
// return null;
// }
return null;
}
versions = JsonUtility.FromJson<Versions>(sdkJson);
versions = initUnityForVerions(versions, networkName, country);
return versions;
}
public static int getLocalCountry()
{
string key = LAST_SELECT_COUNTRY_KEY;
//适配旧版本插件避免直接升级SDK
// if (PlayerPrefs.HasKey(key)) {
// int country = PlayerPrefs.GetInt(key);
// saveLocalCountry(country);
// PlayerPrefs.DeleteKey(key);
// }
// return ATConfigAsset2.Instance.LocalCountry;
return PlayerPrefs.GetInt(key, CHINA_COUNTRY);
}
public static void saveLocalCountry(int country)
{
PlayerPrefs.SetInt(LAST_SELECT_COUNTRY_KEY, country);
PlayerPrefs.Save();
// ATConfigAsset2.Instance.LocalCountry = country;
PlayerPrefs.SetInt(LAST_SELECT_COUNTRY_KEY, country);
}
//获取已安装的network版本包括core network
public static Versions getInstalledNetworkVersion(string networkName, int country)
public static void removeInstalledNetworkVersion(string networkName, int country)
{
string key = networkName + "_" + country;
string sdkJson = PlayerPrefs.GetString(key);
ATLog.log("getInstalledNetworkVersion() >>> networkName: " + networkName + " sdkJson: " + sdkJson + " country: " + country);
if (sdkJson == null || sdkJson.Length == 0)
{
return null;
if (PlayerPrefs.HasKey(key)) {
PlayerPrefs.DeleteKey(key);
}
Versions versions = JsonUtility.FromJson<Versions>(sdkJson);
versions = initUnityForVerions(versions, networkName, country);
return versions;
ATLog.log("removeInstalledNetworkVersion() >>> networkName: " + networkName + " country: " + country);
// ATConfigAsset2.Instance.removeInstalledNetworkVersion(key);
}
private static Versions initUnityForVerions(Versions versions, string networkName, int country)
{
if (versions == null)
@@ -190,24 +232,11 @@ public static bool isDebug = false;
return defaultResult;
}
public static int getLocalCountry()
{
return PlayerPrefs.GetInt(LAST_SELECT_COUNTRY_KEY, CHINA_COUNTRY); //默认是国内
// return CHINA_COUNTRY;
}
public static bool isSelectedChina()
{
return getLocalCountry() == CHINA_COUNTRY;
}
public static void removeInstalledNetworkVersion(string networkName, int country)
{
// int country = getLocalCountry();
PlayerPrefs.DeleteKey(networkName + "_" + country);
}
public static string[] getNetworkFilesPath(string networkName, int country)
{
// if (networkName.Equals(ATIntegrationManager.AnyThinkNetworkName)) {

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 6bfb7071ec4964e539ff5cf42d38b69c
guid: cceee32f5d81d45d2969563d041f6183
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,105 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Serialization;
// using Newtonsoft.Json;
namespace AnyThink.Scripts.Assets
{
public class ConfigData {
public int localCountry = 1;
public Dictionary<string, string> installedNetworkVersion = new Dictionary<string, string>();
}
public class ATConfigAsset
{
public string filePath = "Assets/AnyThinkPlugin/Resources/ATConfigData.json";
private static readonly object lockObject = new object(); // 创建一个静态对象作为锁
private static ATConfigAsset instance;
private ConfigData configData;
private ATConfigAsset() {
}
public static ATConfigAsset Instance
{
get
{
if (instance == null)
{
instance = new ATConfigAsset();
}
return instance;
}
}
public int getLocalCountry() {
getJsonFile();
return Instance.configData.localCountry;
}
public void setLocalCountry(int country) {
configData.localCountry = country;
updateJsonFile();
}
public void saveInstalledNetworkVersion(string key, string version)
{
configData.installedNetworkVersion[key] = version;
ATLog.log("updateJsonFile() >>> saveInstalledNetworkVersion: key = " + key + " version = " + version);
updateJsonFile();
}
public void removeInstalledNetworkVersion(string key)
{
ATLog.log("updateJsonFile() >>> removeInstalledNetworkVersion: key = " + key);
if (configData.installedNetworkVersion.ContainsKey(key)) {
configData.installedNetworkVersion.Remove(key);
}
updateJsonFile();
}
public string getInstalledNetworkVersion(string key)
{
getJsonFile();
if (Instance.configData.installedNetworkVersion.ContainsKey(key)) {
return Instance.configData.installedNetworkVersion[key];
}
return "";
}
private void updateJsonFile() {
// lock(lockObject) {
// if (configData == null) {
// configData = new ConfigData();
// }
// string json = JsonConvert.SerializeObject(configData);
// System.IO.File.WriteAllText(filePath, json);
// ATLog.log("updateJsonFile() >>> json: " + json);
// }
}
private void getJsonFile() {
// lock(lockObject) {
// if (!Directory.Exists(filePath)) {
// configData = new ConfigData();
// updateJsonFile();
// }
// string jsonString = System.IO.File.ReadAllText(filePath);
// ATLog.log("getJsonFile() >>> jsonString: " + jsonString);
// Instance.configData = JsonConvert.DeserializeObject<ConfigData>(jsonString);
// }
}
}
}

View File

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

View File

@@ -0,0 +1,83 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
using UnityEngine.Serialization;
namespace AnyThink.Scripts.Assets
{
[Serializable]
public class SerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue>
{
}
public class ATConfigAsset2 : ScriptableObject
{
public const string SettingsExportPath = "Assets/AnyThinkPlugin/Resources/Assets/ATConfigData.asset";
private static ATConfigAsset2 instance;
public static ATConfigAsset2 Instance
{
get
{
if (instance == null)
{
string settingsFilePath = SettingsExportPath;
var settingsDir = Path.GetDirectoryName(settingsFilePath);
if (!Directory.Exists(settingsDir))
{
Directory.CreateDirectory(settingsDir);
}
// instance = AssetDatabase.LoadAssetAtPath<ATConfigAsset>(settingsFilePath);
instance = Resources.Load<ATConfigAsset2>(settingsFilePath);
if (instance != null) return instance;
instance = CreateInstance<ATConfigAsset2>();
AssetDatabase.CreateAsset(instance, settingsFilePath);
}
return instance;
}
}
[SerializeField] SerializableDictionary<string, string> installedNetworkVersion = new SerializableDictionary<string, string>();
// [SerializeField] string installedNetworkVersionJson = string.Empty;
[SerializeField] int localCountry = 1;
public int LocalCountry
{
get { return Instance.localCountry; }
set { Instance.localCountry = value; }
}
public void saveInstalledNetworkVersion(string key, string version)
{
Instance.installedNetworkVersion[key] = version;
}
public void removeInstalledNetworkVersion(string key)
{
if (Instance.installedNetworkVersion.ContainsKey(key)) {
Instance.installedNetworkVersion.Remove(key);
}
}
public string getInstalledNetworkVersion(string key)
{
if (Instance.installedNetworkVersion.ContainsKey(key)) {
return Instance.installedNetworkVersion[key];
}
return "";
}
public void SaveAsync()
{
EditorUtility.SetDirty(instance);
}
}
}

View File

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

View File

@@ -53,7 +53,7 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
public static PluginData parsePluginDataJson(string serverPluginVersionJson)
{
ATLog.log("plugin version data: " + serverPluginVersionJson);
ATLog.log("parsePluginDataJson plugin version data: " + serverPluginVersionJson);
try
{
@@ -62,6 +62,7 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
ServerPluginVersion serverPluginVersion = JsonUtility.FromJson<ServerPluginVersion>(serverPluginVersionJson);
pluginData.networkUrlVersion = serverPluginVersion.networkUrlVersion;
pluginData.country = ATConfig.getLocalCountry();
// pluginData.country = 1;
pluginData.pluginVersion = serverPluginVersion.pluginVersion;
return pluginData;
}
@@ -116,7 +117,7 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
}
latestVersion.Unity = pluginData.pluginVersion;
coreNetwork.LatestVersions = latestVersion;
ATLog.log("coreNetwork latestVersion: Android=" + latestVersion.Android);
ATLog.log("coreNetwork latestVersion: " + latestVersion + " curVerions: " + curVerions);
if (curVerions != null)
{
coreNetwork.CurrentVersions = curVerions;

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: ca6f64ad482de4a5aa184f487313de57
guid: 576fff4f2b7dd423684961e90cf9e6d5
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 95bc78f07c0814a968d38ba189ba7ed4
guid: 6e94dc3c256ae4d7b93f6dc4d2fe1b72
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 1c2384eee7cf4456e9d116ab275c07b5
guid: bd7ab13837946459a934fb64b4a54f7b
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -108,7 +108,7 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
//解析Anythink的版本数据
string anythinkVersionJson = anythinkVersionRequest.downloadHandler.text;
PluginData pluginData = ATDataUtil.parsePluginDataJson(anythinkVersionJson);
Debug.Log("loadPluginData succeed.");
Debug.Log("loadPluginData succeed. country: " + pluginData.country);
callback(pluginData);
}
}
@@ -118,16 +118,17 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
{
Network network = pluginData.anyThink;
int country = pluginData.country;
ATLog.log("downloadCorePlugin() >>> network: " + network);
if (network == null)
{
return;
}
ATLog.log("downloadCorePlugin() >>> networkName: " + network.Name + " country: " + country);
bool isInstalled = ATConfig.isNetworkInstalled(network.Name, country);
ATLog.log("downloadCorePlugin() >>> isInstalled: " + isInstalled);
if (!isInstalled)
{
downloadPlugin(network, false);
downloadPlugin(network);
// ATEditorCoroutine.startCoroutine(downloadPluginWithEnumerator(network, false));
} else {
handlerVersionAdapter(pluginData);
@@ -156,11 +157,11 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
{
uninstallNetwork(network, country);
}
downloadPlugin(network, false);
downloadPlugin(network);
}
else
{
downloadPlugin(network, true);
downloadPlugin(network);
}
}
@@ -308,7 +309,7 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
network.DownloadUrl = ATNetInfo.getPluginDownloadUrl(pluginVersion);
//https://topon-sdk-release.oss-cn-hangzhou.aliyuncs.com/Unity/Plugin/2.0.0/AnyThinkPlugin_2.0.0.unitypackage
var path = Path.Combine(Application.temporaryCachePath, network.PluginFileName);
ATLog.log("downloadPluginWithEnumerator() >>> path: " + path);
ATLog.log("downloadAnyThinkPlugin() >>> path: " + path);
#if UNITY_2017_2_OR_NEWER
var downloadHandler = new DownloadHandlerFile(path);
#else

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 6db074a8f860d40e8b8fd6a1e459ec50
guid: ca09ecd1405454636bb7d71caa70d821
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -101,17 +101,17 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
// Load uninstall icon texture.
var uninstallIconData = File.ReadAllBytes(ATSdkUtil.GetAssetPathForExportPath(uninstallIconExportPath));
uninstallIcon = new Texture2D(0, 0, TextureFormat.RGBA32, false); // 1. Initial size doesn't matter here, will be automatically resized once the image asset is loaded. 2. Set mipChain to false, else the texture has a weird blurry effect.
uninstallIcon = new Texture2D(100, 100, TextureFormat.RGBA32, false); // 1. Initial size doesn't matter here, will be automatically resized once the image asset is loaded. 2. Set mipChain to false, else the texture has a weird blurry effect.
uninstallIcon.LoadImage(uninstallIconData);
// Load alert icon texture.
var alertIconData = File.ReadAllBytes(ATSdkUtil.GetAssetPathForExportPath(alertIconExportPath));
alertIcon = new Texture2D(0, 0, TextureFormat.RGBA32, false);
alertIcon = new Texture2D(100, 100, TextureFormat.RGBA32, false);
alertIcon.LoadImage(alertIconData);
// Load warning icon texture.
var warningIconData = File.ReadAllBytes(ATSdkUtil.GetAssetPathForExportPath(warningIconExportPath));
warningIcon = new Texture2D(0, 0, TextureFormat.RGBA32, false);
warningIcon = new Texture2D(100, 100, TextureFormat.RGBA32, false);
warningIcon.LoadImage(warningIconData);
ATLog.log("Awake() >>> called");
@@ -179,6 +179,7 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
if (GUI.changed)
{
ATPluginSetting.Instance.SaveAsync();
AssetDatabase.SaveAssets();
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 06d48237d6b6443f1b7cb368fc134467
guid: 7466442bb0ff7449d8e1f8073567eb77
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -5,25 +5,28 @@ using System.Linq;
using UnityEditor;
using UnityEngine;
public class ATLog {
public static void log(string msg)
public class ATLog
{
public static void log (string msg)
{
#if AnyThinkSDKEditor
// string msg =
Debug.Log(msg);
Debug.Log (msg);
#endif
}
public static void log(string tag, string msg)
public static void log (string tag, string msg)
{
Debug.Log(tag + ": " + msg);
Debug.Log (tag + ": " + msg);
}
public static void logFormat(string msg, object[] args)
{
Debug.LogFormat(msg, args);
}
public static void logError(string msg)
public static void logFormat (string msg, object[] args)
{
Debug.LogError(msg);
Debug.LogFormat (msg, args);
}
public static void logError (string msg)
{
Debug.LogError (msg);
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 00b0a6e1f40684d3990b321d49f431b4
guid: e034a99664fd34b1fbdbcb8a6bd2b21e
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,24 +1,22 @@
//菜单栏
using UnityEditor;
using UnityEngine;
// using DownloadManager;
namespace AnyThink.Scripts.IntegrationManager.Editor
{
#if AnyThinkSDKEditor
public class AnyThinkMenuItems : MonoBehaviour
{
#if AnyThinkSDKEditor
/**
* The special characters at the end represent a shortcut for this action.
*
* % - ctrl on Windows, cmd on macOS
* # - shift
* & - alt
*
* So, (shift + cmd/ctrl + t) will launch the integration manager
*/
* The special characters at the end represent a shortcut for this action.
*
* % - ctrl on Windows, cmd on macOS
* # - shift
* & - alt
*
* So, (shift + cmd/ctrl + t) will launch the integration manager
*/
[MenuItem("AnyThink/SDK Manager %#t")]
private static void IntegrationManager()
{
@@ -29,12 +27,13 @@ namespace AnyThink.Scripts.IntegrationManager.Editor
[MenuItem("AnyThink/Documentation")]
public static void Documentation()
{
if (ATConfig.isSelectedChina()) {
Application.OpenURL("https://docs.toponad.com/#/zh-cn/unity/unity_doc/unity_access_plugin_des_doc");
} else {
Application.OpenURL("https://docs.toponad.com/#/en-us/unity/unity_doc/unity_access_doc_new?id=_3-integration");
}
// if (ATConfig.isSelectedChina()) {
// Application.OpenURL("https://newdocs.toponad.com/docs/lgfbO4");
// } else {
// Application.OpenURL("https://docs.toponad.com/#/en-us/unity/unity_doc/unity_access_doc_new?id=_3-integration");
// }
Application.OpenURL("https://newdocs.toponad.com/docs/lgfbO4");
}
}
#endif
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 830af66d7a0ef48aeba18a35f3626b1a
guid: 839a03939354b41358303d5e308e1530
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 65fa7225327184fcdbf3ec4d235585f9
guid: e6b495c82aab14904a12916fb308a19f
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 1b84d4dee1dff41c89fcad01c952ca4c
guid: 74c9441c35d2f47f8b9642d36ec88750
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: faaeb0026391549249b6b8bb9b2c6078
guid: ef9c052202b484fba97a4a35ea42d7e6
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 483a01338fa974b4498cd71261d6e8b9
guid: 87bccae0237fd4a41ac446d6636f95e0
AssemblyDefinitionImporter:
externalObjects: {}
userData: