65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
|
|
using System;
|
|||
|
|
using System.Threading;
|
|||
|
|
using Cysharp.Threading.Tasks;
|
|||
|
|
using Stary.Evo;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using YooAsset;
|
|||
|
|
|
|||
|
|
namespace Main
|
|||
|
|
{
|
|||
|
|
public interface IVideoTableData : ITableData
|
|||
|
|
{
|
|||
|
|
UniTask LoadData();
|
|||
|
|
UniTask<Stary.Evo.TableTextConversion.VideoTableData.MessageInfo> PlayVideoName(string vidid);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public class VideoTableData : IVideoTableData, IDisposable
|
|||
|
|
{
|
|||
|
|
public string TableName => "Config_VideoTableData";
|
|||
|
|
public bool IsLoad { get; set; }
|
|||
|
|
private Stary.Evo.TableTextConversion.VideoTableData videoTableDatas;
|
|||
|
|
|
|||
|
|
|
|||
|
|
public async UniTask LoadData()
|
|||
|
|
{
|
|||
|
|
var handle = YooAssets.LoadAssetAsync<Stary.Evo.TableTextConversion.VideoTableData>(TableName);
|
|||
|
|
await handle.Task;
|
|||
|
|
videoTableDatas = handle.GetAssetObject<Stary.Evo.TableTextConversion.VideoTableData>();
|
|||
|
|
if (videoTableDatas == null)
|
|||
|
|
{
|
|||
|
|
Debug.LogError($"加载视频表失败,请排查config下是否存在【{TableName}】表");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
IsLoad = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
async UniTask<Stary.Evo.TableTextConversion.VideoTableData.MessageInfo> IVideoTableData.PlayVideoName(
|
|||
|
|
string vidid)
|
|||
|
|
{
|
|||
|
|
if (!IsLoad)
|
|||
|
|
{
|
|||
|
|
await LoadData();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var info = videoTableDatas.infos.Find(x => x.vidid == vidid);
|
|||
|
|
if (info != null && !info.filename.Contains("Video"))
|
|||
|
|
{
|
|||
|
|
info.filename = "Video_" + info.filename;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (info != null && !info.videoframeName.Contains("Sprites"))
|
|||
|
|
{
|
|||
|
|
info.videoframeName = "Sprites_" + info.videoframeName;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return info;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void Dispose()
|
|||
|
|
{
|
|||
|
|
videoTableDatas = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|