Files
plugin-library/Assets/05.TableTextConversion/RunTime/Core/VideoTableDataCore.cs

66 lines
1.7 KiB
C#
Raw Normal View History

2025-09-04 11:43:35 +08:00
using System;
using Cysharp.Threading.Tasks;
using UnityEngine;
2025-11-12 14:33:55 +08:00
#if YooAssets
2025-09-04 11:43:35 +08:00
using YooAsset;
2025-11-12 14:33:55 +08:00
#endif
2025-09-04 11:43:35 +08:00
2025-09-10 11:15:18 +08:00
namespace Stary.Evo.TableTextConversion
2025-09-04 11:43:35 +08:00
{
2025-09-10 11:15:18 +08:00
public interface IVideoTableDataCore : ITableDataCore
2025-09-04 11:43:35 +08:00
{
UniTask LoadData();
2025-11-12 14:22:04 +08:00
UniTask<VideoEntity> PlayVideoAssetName(string vidid);
2025-09-04 11:43:35 +08:00
}
2025-11-12 14:22:04 +08:00
#if YooAssets
2025-09-10 11:15:18 +08:00
public class VideoTableDataCore : IVideoTableDataCore, IDisposable
2025-09-04 11:43:35 +08:00
{
public string TableName => "Config_VideoTableData";
public bool IsLoad { get; set; }
2025-11-12 14:22:04 +08:00
private VideoTableData videoTableDatas;
2025-09-04 11:43:35 +08:00
public async UniTask LoadData()
{
2025-11-12 14:22:04 +08:00
var handle = YooAssets.LoadAssetAsync<VideoTableData>(TableName);
2025-09-04 11:43:35 +08:00
await handle.Task;
2025-11-12 14:22:04 +08:00
videoTableDatas = handle.GetAssetObject<VideoTableData>();
2025-09-04 11:43:35 +08:00
if (videoTableDatas == null)
{
Debug.LogError($"加载视频表失败请排查config下是否存在【{TableName}】表");
return;
}
2025-11-12 14:22:04 +08:00
2025-09-04 11:43:35 +08:00
IsLoad = true;
}
2025-11-12 14:22:04 +08:00
public async UniTask<VideoEntity> PlayVideoAssetName(string vidid)
2025-09-04 11:43:35 +08:00
{
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;
}
}
2025-11-12 14:22:04 +08:00
#endif
2025-09-04 11:43:35 +08:00
}