zip压缩加载测试

This commit is contained in:
2025-05-23 18:26:47 +08:00
parent ada423ac91
commit cbd48e8411
147 changed files with 7855 additions and 6 deletions

View File

@@ -0,0 +1,184 @@
using Cysharp.Threading.Tasks;
using Stary.Evo;
using UnityEngine;
using YooAsset;
namespace Main
{
public interface IAudioTableData : IData
{
UniTask LoadData(string audiotabledata_asset, string uitabledata_asset);
Stary.Evo.TableTextConversion.AudioTableData.MessageInfo GetAudioInfo(string auid);
UniTask<AudioClip> GetAudioClip(string auid);
AudioTableData.AudioToUITableData GetAudioToUIInfo(string auid);
UniTask<AudioTableData.AudioToUIData> GetAudioClipToUISprite(string auid);
Stary.Evo.TableTextConversion.UITableData.MessageInfo GetUIInfo(string uiid);
UniTask<Sprite> GetUISprite(string uiid);
}
public class AudioTableData : AbstractData, IAudioTableData
{
private Stary.Evo.TableTextConversion.AudioTableData audioTableData;
private Stary.Evo.TableTextConversion.UITableData uiTableDatas;
protected override async void OnInit()
{
}
public async UniTask LoadData(string audiotabledata_asset, string uitabledata_asset)
{
var audioHandle =
YooAssets.LoadAssetAsync<Stary.Evo.TableTextConversion.AudioTableData>(audiotabledata_asset);
await audioHandle.Task;
audioTableData = audioHandle.GetAssetObject<Stary.Evo.TableTextConversion.AudioTableData>();
var UIHandle =
YooAssets.LoadAssetAsync<Stary.Evo.TableTextConversion.UITableData>(uitabledata_asset);
await UIHandle.Task;
uiTableDatas = UIHandle.GetAssetObject<Stary.Evo.TableTextConversion.UITableData>();
}
/// <summary>
/// 获取音频数据
/// </summary>
/// <param name="auid"></param>
/// <returns></returns>
public Stary.Evo.TableTextConversion.AudioTableData.MessageInfo GetAudioInfo(string auid)
{
var info = audioTableData.infos.Find(x => x.auid == auid);
if (info != null && !info.filename.Contains("Audios"))
{
info.filename = "Audios_" + info.filename;
}
return info;
}
/// <summary>
/// 获取音频
/// </summary>
/// <param name="auid"></param>
/// <returns></returns>
public async UniTask<AudioClip> GetAudioClip(string auid)
{
var info=GetAudioInfo(auid);
var handle = YooAssets.LoadAssetAsync<AudioClip>(info.filename);
await handle.Task;
if (handle.Status == EOperationStatus.Succeed)
{
return handle.GetAssetObject<AudioClip>();
}
else
{
Debug.LogError(
$"加载音频失败,错误的id为:{auid},错误的音频名称为:{info.filename},错误的错误信息为:{handle.LastError}");
return null;
}
}
/// <summary>
/// 获取音频数据获取UI数据
/// </summary>
/// <param name="auid"></param>
/// <returns></returns>
public AudioToUITableData GetAudioToUIInfo(string auid)
{
var info=GetAudioInfo(auid);
Stary.Evo.TableTextConversion.UITableData.MessageInfo messageInfo = GetUIInfo(info.uirelated);
if (messageInfo != null)
{
return new AudioToUITableData()
{
audioFileName = info.filename,
UIMessageInfo = messageInfo
};
}
else
{
Debug.LogError($"没有找到对应的uiid,错误的id为:{info.uirelated}");
return default;
}
}
/// <summary>
/// 获取音频数据获取UI数据
/// </summary>
/// <param name="auid"></param>
/// <returns></returns>
public async UniTask<AudioToUIData> GetAudioClipToUISprite(string auid)
{
var info=GetAudioToUIInfo(auid);
AudioClip audioClip = await GetAudioClip(auid);
Sprite sprite = await GetUISprite(info.UIMessageInfo.uiid);
if (audioClip != null && sprite != null)
{
return new AudioToUIData()
{
audioClip = audioClip,
sprite = sprite
};
}
else
{
Debug.LogError($"没有找到对应的uiid,错误的id为:{info.UIMessageInfo.uiid}");
return default;
}
}
/// <summary>
/// 获取UI数据
/// </summary>
/// <param name="uiid"></param>
/// <returns></returns>
public Stary.Evo.TableTextConversion.UITableData.MessageInfo GetUIInfo(string uiid)
{
var info = uiTableDatas.infos.Find(x => x.uiid == uiid);
if (info != null && !info.filename.Contains("Sprites_"))
{
info.filename = "Sprites_" + info.filename;
}
return info;
}
/// <summary>
/// 获取UI
/// </summary>
/// <param name="auid"></param>
/// <returns></returns>
public async UniTask<Sprite> GetUISprite(string uiid)
{
var info = GetUIInfo(uiid);
var handle = YooAssets.LoadAssetAsync<Sprite>(info.filename);
await handle.Task;
if (handle.Status == EOperationStatus.Succeed)
{
return handle.GetAssetObject<Sprite>();
}
else
{
Debug.LogError(
$"加载ui失败,错误的id为:{uiid},错误的ui名称为:{info.filename},错误的错误信息为:{handle.LastError}");
return null;
}
}
public override void Dispose()
{
}
public struct AudioToUITableData
{
public string audioFileName;
public Stary.Evo.TableTextConversion.UITableData.MessageInfo UIMessageInfo;
}
public struct AudioToUIData
{
public AudioClip audioClip;
public Sprite sprite;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 336c695a4299453bb325ceeaaa9bb4ed
timeCreated: 1745736803

View File

@@ -0,0 +1,87 @@
using System;
using System.Threading;
using Cysharp.Threading.Tasks;
using Main;
using Stary.Evo;
using Stary.Evo.UIFarme;
using UnityEngine;
using YooAsset;
namespace Main
{
public interface IDigitalHumanVoiceSystem : ISystem
{
UniTask PlayVoice(string auid, Action callback = null);
UniTask PlayTest(string auid, Action callback = null);
void PlayImage(string uiid);
}
public class DigitalHumanVoiceSystem : AbstractSystem, IDigitalHumanVoiceSystem
{
private CancellationTokenSource tokenSource;
public async UniTask PlayVoice(string auid, Action callback = null)
{
DisposeTokenSource();
tokenSource = new CancellationTokenSource();
var info = this.GetData<IAudioTableData>().GetAudioToUIInfo(auid);
var handle1 = YooAssets.LoadAssetAsync<AudioClip>(info.audioFileName);
await handle1.WithCancellation(tokenSource.Token);
AudioClip audioClip = handle1.GetAssetObject<AudioClip>();
var handle2 = YooAssets.LoadAssetAsync<Sprite>(info.UIMessageInfo.filename);
await handle2.WithCancellation(tokenSource.Token);
Sprite sprite = handle2.GetAssetObject<Sprite>();
MainArchitecture.Interface.GetSystem<IDigitalHuman>().SetTalkState(audioClip, sprite);
await UniTask.Delay(TimeSpan.FromSeconds(audioClip.length+1f), cancellationToken: tokenSource.Token);
callback?.Invoke();
}
public async UniTask PlayTest(string auid, Action callback = null)
{
DisposeTokenSource();
tokenSource = new CancellationTokenSource();
var info = this.GetData<IAudioTableData>().GetAudioToUIInfo(auid);
var handle1 = YooAssets.LoadAssetAsync<AudioClip>(info.audioFileName);
await handle1.WithCancellation(tokenSource.Token);
AudioClip audioClip = handle1.GetAssetObject<AudioClip>();
MainArchitecture.Interface.GetSystem<IDigitalHuman>().SetTalkState(audioClip, info.UIMessageInfo.subtitle);
await UniTask.Delay(TimeSpan.FromSeconds(audioClip.length), cancellationToken: tokenSource.Token);
callback?.Invoke();
}
public async void PlayImage(string uiid)
{
DisposeTokenSource();
tokenSource = new CancellationTokenSource();
var info =this.GetData<IAudioTableData>().GetUIInfo(uiid);
var handle1 = YooAssets.LoadAssetAsync<Sprite>(info.filename);
await handle1.WithCancellation(tokenSource.Token);
Sprite sprite = handle1.GetAssetObject<Sprite>();
MainArchitecture.Interface.GetSystem<IDigitalHuman>().SetTalkState( sprite);
}
protected override void OnInit()
{
}
private void DisposeTokenSource()
{
if (tokenSource != null && !tokenSource.IsCancellationRequested)
{
tokenSource.Cancel();
tokenSource.Dispose();
tokenSource = null;
}
}
public override void Dispose()
{
DisposeTokenSource();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 67318e7492e648129b1de2df6f176a72
timeCreated: 1745216067

View File

@@ -0,0 +1,224 @@
using System;
using System.Collections.Generic;
using System.Threading;
using Cysharp.Threading.Tasks;
using DG.Tweening;
using Stary.Evo;
using Stary.Evo.RKTools;
using UnityEngine;
namespace Main
{
public interface IClickSystem : ISystem
{
void AddClickIntervalEvent(Action callback);
void StartTime();
void EndClick();
void BindClickEvent(List<ClickElementChildren> clickElementChildrens, Action<GameObject> callback);
void ClickBreatheTween(List<ClickElementChildren> tweenList, Transform tweenTarget);
bool IsElementChildrenClick();
}
public class ClickSystem : AbstractSystem, IClickSystem
{
// public Sequence loopTargetTween;
/// <summary>
/// 点击计时器
/// </summary>
public float time;
private CancellationTokenSource tokenSource;
private List<ClickElementChildren> clickElementChildrens;
private Action ClickIntervalEvent;
protected override void OnInit()
{
}
public void StartTime()
{
time = 0;
Update();
}
public void BindClickEvent(List<ClickElementChildren> clickElementChildrens, Action<GameObject> callback)
{
StartTime();
this.clickElementChildrens = clickElementChildrens;
//绑定点击事件
foreach (var child in clickElementChildrens)
{
child.transform.gameObject.ObjectAddTouchEvent(callback);
}
}
public void ClickBreatheTween(List<ClickElementChildren> tweenList, Transform tweenTarget)
{
Debug.Log("UnityEvo: 点击呼吸");
time = 0;
foreach (var tween in tweenList)
{
tween.transform.gameObject.ObjectResumeTouchEvent();
// if (tween.transform == tweenTarget)
// {
// tween.isClick = true;
// }
if (tween.transform == tweenTarget)
{
tween.isClick = true;
tween.transform.GetComponent<Animator>().CrossFade("dianji_idle", 0.2f);
this.SendEvent<ModeType, ClickElementChildren>(ModeType.PLayAudioOrVideo,tween);
tweenTarget.gameObject.ObjectPauseTouchEvent();
// if (loopTargetTween != null)
// {
// loopTargetTween.Kill();
// loopTargetTween = null;
// }
//
// loopTargetTween = DOTween.Sequence();
// loopTargetTween.Append(tweenTarget.DOScale(tweenTarget.lossyScale * 1.3f, 1f));
//
// loopTargetTween.SetLoops(6, LoopType.Yoyo);
// loopTargetTween.OnKill(() =>
// {
// if (tweenTarget != null)
// tweenTarget.DOScale(Vector3.one, 0.3f);
// });
// loopTargetTween.Play();
continue;
}
// tween.transform.DOKill();
// tween.transform.DOScale(Vector3.one * 0.9f, 0.5f);
tween.transform.GetComponent<Animator>().CrossFade("dianji_nood", 1f);
}
}
public void AddClickIntervalEvent(Action callback)
{
this.ClickIntervalEvent = callback;
}
public bool IsElementChildrenClick()
{
//是否全部已经点击
for (int i = 0; i < clickElementChildrens.Count; i++)
{
if (clickElementChildrens[i].isClick == false)
{
return false;
}
}
return true;
}
public void EndClick()
{
// if (loopTargetTween != null)
// {
// loopTargetTween.Kill();
// loopTargetTween = null;
// }
time = 0;
if (tokenSource != null)
{
tokenSource?.Cancel();
tokenSource?.Dispose();
tokenSource = null;
}
foreach (var children in clickElementChildrens)
{
children.transform.gameObject.ObjectRemoveTouchEvent();
children.transform.GetComponent<Animator>().CrossFade("dianji_disappear", 0.2f);
}
}
private async void Update()
{
//TODO暂时禁用
// if (tokenSource != null)
// {
// tokenSource?.Cancel();
// }
//
// tokenSource = new CancellationTokenSource();
// try
// {
// while (time <= 11 && !tokenSource.IsCancellationRequested)
// {
// time += Time.deltaTime;
//
// if (time >= 10)
// {
// Debug.Log("UnityEvo:执行未点击间隔事件");
// time = 0;
// ClickIntervalEvent?.Invoke();
// }
//
// await UniTask.Yield(tokenSource.Token);
// }
// }
// catch (OperationCanceledException e)
// {
// Debug.Log("UnityEvo: 取消任务:" + e);
// }
}
public override void Dispose()
{
if (tokenSource != null)
{
tokenSource?.Cancel();
tokenSource?.Dispose();
tokenSource = null;
}
// if (loopTargetTween != null)
// {
// loopTargetTween.Kill();
// loopTargetTween = null;
// }
}
}
public class ClickElementChildren
{
public bool isClick = false;
public string[] auid;
public string vid;
public Transform transform;
public Transform targetTransform;
public ClickElementChildren(Transform child)
{
this. transform = child;
}
public ClickElementChildren(Transform child, string[] auid, string vid)
{
this.auid = auid;
this.vid = vid;
this. transform = child;
}
public ClickElementChildren(Transform child,Transform targetTransform , string[] auid, string vid)
{
this.auid = auid;
this.vid = vid;
this. transform = child;
this.targetTransform= targetTransform;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 206bc7f4b09d456898aed456017e6529
timeCreated: 1745915168

View File

@@ -0,0 +1,103 @@
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 IntroPanel : BasePanel
{
static readonly string path = "IntroPanel";
private Image intro;
private LocalTransformInfo transformInfo;
public IntroPanel()
{
}
public override void Initialize(GameObject panelGo)
{
base.Initialize(panelGo);
intro = activePanel.transform.Find("Intro").GetComponent<Image>();
transformInfo = activePanel.transform.GetComponent<LocalTransformInfo>();
intro.gameObject.SetActive(false);
}
public override void OnEnter()
{
base.OnEnter();
this.RegisterEvent<IntroType, string, string>(IntroType.IntroSprite, OnClickPreviousIntro);
this.RegisterEvent<IntroType, RuntimeAnimatorController, string>(IntroType.IntroAnimation, OnAddAnimation);
this.RegisterEvent<IntroType, string, string>(IntroType.IntroAudio, OnClickPreviousIntroAudio);
}
public override void OnExit(float delay = 0)
{
base.OnExit(delay);
intro.sprite = null;
intro.gameObject.SetActive(false);
this.UnRegisterEvent<IntroType, string, string>(IntroType.IntroSprite, OnClickPreviousIntro);
this.UnRegisterEvent<IntroType, string, string>(IntroType.IntroAudio, OnClickPreviousIntroAudio);
this.UnRegisterEvent<IntroType, RuntimeAnimatorController, string>(IntroType.IntroAnimation, OnAddAnimation);
var animator = intro.transform.GetComponent<Animator>();
if (animator != null)
{
GameObject.Destroy(animator);
}
}
public async void OnAddAnimation(RuntimeAnimatorController animatorController, string desc)
{
var animator = intro.transform.GetOrAddComponent<Animator>();
animator.runtimeAnimatorController = animatorController;
intro.SetNativeSize();
intro.gameObject.SetActive(true);
transformInfo.Set(desc);
}
public async void OnClickPreviousIntro(string spriteName, string desc)
{
var handle= YooAssets.LoadAssetAsync<Sprite>(spriteName);
await handle.Task;
intro.sprite = handle.GetAssetObject<Sprite>();
intro.SetNativeSize();
intro.gameObject.SetActive(true);
transformInfo.Set(desc);
}
public async void OnClickPreviousIntroAudio(string auid, string desc)
{
var info = await this.GetData<IAudioTableData>().GetAudioClipToUISprite(auid);
AudioCoreManager.PlayVoice(new AudioData()
{
clip = info.audioClip,
});
SetIntroSprite(info.sprite, desc);
}
private void SetIntroSprite(Sprite sprite, string desc)
{
intro.sprite = sprite;
intro.SetNativeSize();
intro.gameObject.SetActive(true);
transformInfo.Set(desc);
}
public enum IntroType
{
IntroSprite,
IntroAudio,
IntroAnimation
}
}
}

View File

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

View File

@@ -0,0 +1,46 @@
using Cysharp.Threading.Tasks;
using Stary.Evo;
using YooAsset;
namespace Main
{
public interface IVideoTableData : IData
{
UniTask LoadData(string videotabledata_asset);
Stary.Evo.TableTextConversion.VideoTableData.MessageInfo PlayVideoName(string vidid);
}
public class VideoTableData : AbstractData, IVideoTableData
{
private Stary.Evo.TableTextConversion.VideoTableData videoTableDatas;
protected override async void OnInit()
{
}
public async UniTask LoadData(string videotabledata_asset)
{
var handle = YooAssets.LoadAssetAsync<Stary.Evo.TableTextConversion.VideoTableData>(videotabledata_asset);
await handle.Task;
videoTableDatas = handle.GetAssetObject<Stary.Evo.TableTextConversion.VideoTableData>();
}
public Stary.Evo.TableTextConversion.VideoTableData.MessageInfo PlayVideoName(string vidid)
{
var info = videoTableDatas.infos.Find(x => x.vidid == vidid);
if (info != null && !info.filename.Contains("Video"))
{
info.filename="Video_"+info.filename;
}
return info;
}
public override void Dispose()
{
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2c1c8c62f563482ea249c39b08cab4fa
timeCreated: 1745311080