Files
plugin-library/Assets/Main/HotfixUpdateScript/Runtime/HotUpdate/LasterDoMain/VideoTableData.cs

63 lines
1.9 KiB
C#
Raw Normal View History

2025-07-02 10:05:26 +08:00
using System;
using System.Threading;
using Cysharp.Threading.Tasks;
2025-05-23 18:26:47 +08:00
using Stary.Evo;
2025-07-02 10:05:26 +08:00
using UnityEngine;
2025-05-23 18:26:47 +08:00
using YooAsset;
namespace Main
{
public interface IVideoTableData : IData
{
UniTask LoadData(string videotabledata_asset);
Stary.Evo.TableTextConversion.VideoTableData.MessageInfo PlayVideoName(string vidid);
}
2025-07-02 10:05:26 +08:00
2025-05-23 18:26:47 +08:00
public class VideoTableData : AbstractData, IVideoTableData
{
private Stary.Evo.TableTextConversion.VideoTableData videoTableDatas;
2025-07-02 10:05:26 +08:00
private CancellationTokenSource _cancellationTokenSource;
2025-05-23 18:26:47 +08:00
protected override async void OnInit()
{
}
public async UniTask LoadData(string videotabledata_asset)
{
2025-07-02 10:05:26 +08:00
_cancellationTokenSource = new CancellationTokenSource();
2025-05-23 18:26:47 +08:00
var handle = YooAssets.LoadAssetAsync<Stary.Evo.TableTextConversion.VideoTableData>(videotabledata_asset);
2025-07-02 10:05:26 +08:00
await handle.WithCancellation(this._cancellationTokenSource.Token);
2025-05-23 18:26:47 +08:00
videoTableDatas = handle.GetAssetObject<Stary.Evo.TableTextConversion.VideoTableData>();
}
2025-07-02 10:05:26 +08:00
2025-05-23 18:26:47 +08:00
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"))
{
2025-07-02 10:05:26 +08:00
info.filename = "Video_" + info.filename;
2025-05-23 18:26:47 +08:00
}
2025-07-02 10:05:26 +08:00
2025-05-23 18:26:47 +08:00
return info;
}
2025-07-02 10:05:26 +08:00
2025-05-23 18:26:47 +08:00
public override void Dispose()
{
2025-07-02 10:05:26 +08:00
try
{
if (_cancellationTokenSource != null && !_cancellationTokenSource.IsCancellationRequested)
{
_cancellationTokenSource.Cancel();
_cancellationTokenSource.Dispose();
}
}
catch (OperationCanceledException e)
{
Debug.Log("异步取消操作");
}
2025-05-23 18:26:47 +08:00
}
}
}