修改main

This commit is contained in:
2025-05-30 14:52:53 +08:00
parent 078f080fcc
commit cd1b718e85
11 changed files with 101 additions and 74 deletions

View File

@@ -12,6 +12,7 @@ namespace R
}
public static class audios
{
public const string au_effect_element_pop_mp3 = "Audios_au_effect_element_pop";
public const string au_x_07_ending1_wav = "Audios_au_X_07_ending1";
public const string au_x_07_ending2_wav = "Audios_au_X_07_ending2";
public const string au_x_07_ending3_wav = "Audios_au_X_07_ending3";
@@ -42,6 +43,7 @@ namespace R
public const string guideball_zone_prefab = "Prefabs_GuideBall_Zone";
public const string kkcontroller_prefab = "Prefabs_KKController";
public const string main_prefab = "Prefabs_Main";
public const string progressbarpanel_prefab = "Prefabs_ProgressBarPanel";
public const string videopanel_prefab = "Prefabs_VideoPanel";
public const string watermark_prefab = "Prefabs_Watermark";
}

View File

@@ -0,0 +1,68 @@
using System;
using Cysharp.Threading.Tasks;
using Stary.Evo;
using Stary.Evo.AudioCore;
using Stary.Evo.InformationSave;
using Stary.Evo.UIFarme;
using UnityEngine;
using UnityEngine.UI;
using YooAsset;
namespace Main
{
public class ProgressBarPanel : BasePanel
{
static readonly string path = "ProgressBarPanel";
private Image _fill;
private Text _fillText;
private Text _fillMessage;
public ProgressBarPanel()
{
}
public override void Initialize(GameObject panelGo)
{
base.Initialize(panelGo);
_fill = activePanel.transform.Find("Fill").GetComponent<Image>();
_fillText = _fill.transform.Find("FillText").GetComponent<Text>();
_fillMessage= _fill.transform.Find("FillMessage").GetComponent<Text>();
_fill.fillAmount = 0;
_fillText.text = "0%";
}
public override void OnEnter()
{
base.OnEnter();
this.RegisterEvent<ProgressBarType,string, float>(ProgressBarType.Add, SetProgressBarValue);
}
public override void OnExit(float delay = 0)
{
base.OnExit(delay);
_fill.fillAmount = 0;
_fillText.text = "0%";
this.UnRegisterEvent<ProgressBarType,string, float>(ProgressBarType.Add, SetProgressBarValue);
}
public async void SetProgressBarValue(string message,float value)
{
_fill.fillAmount = value;
_fillMessage.text = message;
_fillText.text = $"{value:P0}";
if (value >= 1)
{
this.PanelSystem.PopQueue<ProgressBarPanel>();
}
}
public enum ProgressBarType
{
Add,
}
}
}

View File

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

View File

@@ -2,6 +2,6 @@
{
public class WebRequestTools
{
}
}

View File

@@ -11,33 +11,19 @@ namespace Stary.Evo
public class ZipTool
{
// 新增:带进度回调的下载解压方法
public static async UniTask<string[]> DownloadAndUnzipAsync(string url, string extractPath,
public static async UniTask DownloadAndUnzipAsync(string fildId, string extractPath,
Action<float> downloadProgress = null, Action<float> unzipProgress = null)
{
string tempPath = Path.Combine(Application.persistentDataPath, "temp.zip");
try
{
// 下载ZIP文件
using( UnityWebRequest request =WebRequester(url))
{
request.downloadHandler = new DownloadHandlerFile(tempPath);
var operation = request.SendWebRequest();
while (!operation.isDone)
{
downloadProgress?.Invoke(request.downloadProgress);
await UniTask.Yield();
}
if (request.result != UnityWebRequest.Result.Success)
{
throw new Exception($"下载失败:{request.error}");
}
}
string url = $"{AppConfig.IpConfig}/FileLoad/Download/{fildId}";
await WebRequestSystem.GetFile(url, tempPath,downloadProgress);
// 解压下载的文件
return await UnzipAsync(tempPath, extractPath, unzipProgress);
await UnzipAsync(tempPath, extractPath, unzipProgress);
File.Delete(tempPath);
}
finally
{
@@ -50,40 +36,37 @@ namespace Stary.Evo
}
// 修改:添加进度回调参数
public static async UniTask<string[]> UnzipAsync(string zipPath, string extractPath,
public static async UniTask UnzipAsync(string zipPath, string extractPath,
Action<float> progressCallback = null)
{
try
{
List<string> pathList = new List<string>();
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
float totalEntries = archive.Entries.Count;
float processed = 0;
foreach (ZipArchiveEntry entry in archive.Entries)
{
string filePath = Path.Combine(extractPath, entry.FullName);
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
if (!string.IsNullOrEmpty(entry.Name))
{
using (Stream inputStream = entry.Open())
using (FileStream outputStream = File.Create(filePath))
{
await inputStream.CopyToAsync(outputStream);
pathList.Add(outputStream.Name);
}
}
processed++;
float progress = processed / totalEntries;
progressCallback?.Invoke(progress);
Debug.Log($"解压进度: {progress:P0}");
}
}
Debug.Log($"解压完成: {extractPath}");
return pathList.ToArray();
}
catch (Exception ex)
{
@@ -91,6 +74,7 @@ namespace Stary.Evo
throw;
}
}
/// <summary>
/// 自定义网络请求器需要登录
/// </summary>
@@ -99,7 +83,7 @@ namespace Stary.Evo
private static UnityWebRequest WebRequester(string url)
{
var request = new UnityWebRequest(url, UnityWebRequest.kHttpVerbGET);
var authorization = GetAuthorization(AppConfig.USERNAME, AppConfig.PASSWORD);
var authorization = GetAuthorization(AppConfig.UserName, AppConfig.PassWord);
request.SetRequestHeader("AUTHORIZATION", authorization);
return request;
}
@@ -111,6 +95,4 @@ namespace Stary.Evo
return "Basic " + System.Convert.ToBase64String(bytes);
}
}
}

View File

@@ -108,7 +108,7 @@ namespace Main
int index = -1;
for (int i = 0; i < points.Count; i++)
{
if (AppConfig.ASSETPACKGENAME == points[i].Name)
if (AppConfig.PackageDomainName == points[i].Name)
{
index = i;
break;