using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using QFramework;
using Unity.Linq;
namespace QFramework.ZY
{
public partial class ZYArrowBG : UIElement
{
private void Start()
{
gameObject.Children().ForEach(_ =>
{
PlayMultiSeq();
});
}
// 子物体多个RawImage 播放同一个序列帧
private void PlayMultiSeq()
{
Playback pb;
gameObject.TryGetComponent(out pb);
if (pb)
{
Destroy(pb);
}
pb = gameObject.AddComponent();
pb.mode = PlaybackMode.uGUI;
pb.multiOut = true;
pb.uiOutList = new List();
// pb.uiOutList 传入都需要播放的 RawImage 组件
gameObject.GetComponentsInChildren().ForEach(_ => {
pb.uiOutList.Add(_);
});
if (SequencesData.Instance.ZY_ArrowT2Ds == null)
{
pb.LoadSequence("ZY_ArrowT2Ds");
}
else
{
pb.LoadSequence(SequencesData.Instance.ZY_ArrowT2Ds);
}
pb.loop = true;
pb.FPS = 30;
pb.enabled = true;
pb.Play();
}
// 单个RawImage 播放
private void PlaySeq()
{
Playback pb;
gameObject.TryGetComponent(out pb);
if (pb)
{
Destroy(pb);
}
pb = gameObject.AddComponent();
pb.mode = PlaybackMode.uGUI;
pb.rawImage = GetComponent();
pb.loop = true;
if (SequencesData.Instance.ZY_ArrowT2Ds == null)
{
pb.LoadSequence("ZY_ArrowT2Ds");
}
else
{
pb.LoadSequence(SequencesData.Instance.ZY_ArrowT2Ds);
}
pb.FPS = 30;
pb.enabled = true;
pb.Play();
}
protected override void OnBeforeDestroy()
{
}
}
}