using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; using Newtonsoft.Json; using UnityEngine; namespace Stary.Evo { public static class ArtLoadAssetServer { public static string ip; static ArtLoadAssetServer() { //初始化读取资源配置表 HotfixMainResDomain hotfixMainResDomain = Resources.Load("HotfixMainResDomain"); if (hotfixMainResDomain == null) { Debug.LogError($"UnityEvo:读取资源配置表失败【HotfixMainResDomain】...表不存在"); } ip = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig; } /// /// 获取服务器全部作用域 /// public async static Task GetServerDomainAllName() { var serverDomainEntities = await GetServerDomainAll(); List domains = new List(); for (int i = 0; i < serverDomainEntities.Count; i++) { if (serverDomainEntities[i].IsEnable) { domains.Add(serverDomainEntities[i].DomainName); } } return domains.ToArray(); } /// /// 获取全部作用域 /// public static async Task> GetServerDomainAll() { //初始化读取资源配置表 HotfixMainResDomain hotfixMainResDomain = Resources.Load("HotfixMainResDomain"); if (hotfixMainResDomain == null) { Debug.LogError($"UnityEvo:读取资源配置表失败【HotfixMainResDomain】...表不存在"); return null; } ip = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig; //登录 string loginurl = ip + "/Authentication/login"; await WebRequestSystem.Login(loginurl, hotfixMainResDomain.hotfixMainResDomainEntity.username, hotfixMainResDomain.hotfixMainResDomainEntity.password); string url = $"{ip}/ResDomain/GetResDomainAll"; var resDmainRequst = new ResProductRequst() { ProductName = Application.identifier, #if UNITY_EDITOR Platform = UnityEditor.EditorUserBuildSettings.activeBuildTarget.ToString() #else Platform = Application.platform.ToString() #endif }; //获取服务器版本 var resDmainMessageEntity = await WebRequestSystem.Post(url, JsonConvert.SerializeObject(resDmainRequst)); if (resDmainMessageEntity.code == 200) { List resDmainResponse = JsonConvert.DeserializeObject>(resDmainMessageEntity.data.ToString()); ResDmainResponse mainDmainResponse = default; for (int i = 0; i < resDmainResponse.Count; i++) { if (resDmainResponse[i].DomainName == "Main") { mainDmainResponse = resDmainResponse[i]; } } if (mainDmainResponse.DomainName == "Main") { resDmainResponse.Remove(mainDmainResponse); } return resDmainResponse; } return null; } } }