报错修改
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Stary.Evo;
|
||||
using UnityEngine;
|
||||
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;
|
||||
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
|
||||
protected override async void OnInit()
|
||||
{
|
||||
}
|
||||
|
||||
public async UniTask LoadData(string videotabledata_asset)
|
||||
{
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
var handle = YooAssets.LoadAssetAsync<Stary.Evo.TableTextConversion.VideoTableData>(videotabledata_asset);
|
||||
await handle.WithCancellation(this._cancellationTokenSource.Token);
|
||||
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()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_cancellationTokenSource != null && !_cancellationTokenSource.IsCancellationRequested)
|
||||
{
|
||||
_cancellationTokenSource.Cancel();
|
||||
_cancellationTokenSource.Dispose();
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException e)
|
||||
{
|
||||
Debug.Log("异步取消操作");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user