forked from zxl/LaboratoryProtection
47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using Mono.Event;
|
|
using Sirenix.OdinInspector;
|
|
using Sirenix.Serialization;
|
|
using UnityEngine;
|
|
using UnityEngine.Playables;
|
|
|
|
namespace UnityTest.ZXL
|
|
{
|
|
public class TimelineManager : MonoBehaviour
|
|
{
|
|
[SerializeField] private List<PlayableDirector> _playableDirectors = new List<PlayableDirector>();
|
|
|
|
private void Awake()
|
|
{
|
|
foreach (var playableDirector in _playableDirectors)
|
|
{
|
|
playableDirector.stopped += FirePlayableStopped;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// timeline播放结束触发的事件
|
|
/// </summary>
|
|
/// <param name="obj"></param>
|
|
private void FirePlayableStopped(PlayableDirector obj)
|
|
{
|
|
Debug.Log($"timeline {obj.name} is stop");
|
|
EventManager.Instance.FireNow(this, new PlayableStoppedEventArgs(obj));
|
|
var list = obj.gameObject.GetComponentAllChild<Camera>();
|
|
foreach (var camera1 in list)
|
|
{
|
|
camera1.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
#if UNITY_EDITOR
|
|
[Button]
|
|
void Add()
|
|
{
|
|
var go = GameObject.Find("Timeline_M");
|
|
var list = go.GetComponentAllChild<PlayableDirector>();
|
|
_playableDirectors = new List<PlayableDirector>(list);
|
|
}
|
|
#endif
|
|
}
|
|
} |