Files
plugin-library/Assets/00.BuildOriginality/Runtime/ArtLoadAssetServer.cs
2025-10-31 11:18:23 +08:00

84 lines
3.0 KiB
C#

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>("HotfixMainResDomain");
if (hotfixMainResDomain == null)
{
Debug.LogError($"UnityEvo:读取资源配置表失败【HotfixMainResDomain】...表不存在");
}
ip = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
}
/// <summary>
/// 获取服务器全部作用域
/// </summary>
public async static Task<string[]> GetServerDomainAllName()
{
var serverDomainEntities = await GetServerDomainAll();
List<string> domains = new List<string>();
for (int i = 0; i < serverDomainEntities.Count; i++)
{
if (serverDomainEntities[i].IsEnable)
{
domains.Add(serverDomainEntities[i].DomainName);
}
}
return domains.ToArray();
}
/// <summary>
/// 获取全部作用域
/// </summary>
public static async Task<List<ResDmainResponse>> GetServerDomainAll()
{
//初始化读取资源配置表
HotfixMainResDomain hotfixMainResDomain =
Resources.Load<HotfixMainResDomain>("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,
Platform = UnityEditor.EditorUserBuildSettings.activeBuildTarget.ToString(),
};
//获取服务器版本
var resDmainMessageEntity =
await WebRequestSystem.Post(url, JsonConvert.SerializeObject(resDmainRequst));
if (resDmainMessageEntity.code == 200)
{
List<ResDmainResponse> resDmainResponse =
JsonConvert.DeserializeObject<List<ResDmainResponse>>(resDmainMessageEntity.data.ToString());
return resDmainResponse;
}
return null;
}
}
}