You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
683 B
33 lines
683 B
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class Timeline : MonoBehaviour
|
|
{
|
|
[Serializable]
|
|
public class TimelineEvent
|
|
{
|
|
public float waitSeconds;
|
|
public UnityEvent unityEvent;
|
|
}
|
|
|
|
[SerializeField]
|
|
private List<TimelineEvent> _events;
|
|
|
|
private void Start()
|
|
{
|
|
StartCoroutine(PlayTimeline());
|
|
}
|
|
|
|
private IEnumerator PlayTimeline()
|
|
{
|
|
foreach (var timelineEvent in _events)
|
|
{
|
|
yield return new WaitForSeconds(timelineEvent.waitSeconds);
|
|
timelineEvent.unityEvent.Invoke();
|
|
}
|
|
}
|
|
}
|