Files
aibis-dream/Assets/Scripts/SubWay/OutsideCenter.cs
T
2025-06-14 21:09:52 +08:00

55 lines
1.6 KiB
C#

using AibisDream.Kit;
using UnityEngine;
using UnityEngine.Playables;
using System.Collections;
namespace AibisDream
{
public class OutsideCenter : Singleton<OutsideCenter>
{
public BubbleSlotGroup bubbleSlotGroup;
public PlayableDirector director;
public override void OnSingletonInit()
{
// 加载气泡
DialogCanvasManager.Instance.SwitchDialogView(DialogViewType.StandardBubble);
BubbleGroup.Instance.LoadBubbles(bubbleSlotGroup.CollectData());
}
public void PlayTimeline(string timelinePath)
{
StartCoroutine(PlayTimelineCoroutine(timelinePath));
}
public void PlayTimelineAsync(string timelinePath)
{
var timeline = Resources.Load<PlayableAsset>(timelinePath);
if (timeline != null)
{
director.playableAsset = timeline;
director.Play();
}
else
{
Debug.LogError($"Timeline not found at path: {timelinePath}");
}
}
public IEnumerator PlayTimelineCoroutine(string timelinePath)
{
var timeline = Resources.Load<PlayableAsset>(timelinePath);
if (timeline != null)
{
director.playableAsset = timeline;
director.Play();
yield return new WaitForSeconds((float)director.duration);
}
else
{
Debug.LogError($"Timeline not found at path: {timelinePath}");
}
}
}
}