using System.Collections.Generic;
using UnityEngine.Sequences.Timeline;
namespace UnityEngine.Sequences
{
public partial class TimelineSequence
{
///
/// Returns true if the TimelineSequence has at least one related scene ().
///
///
internal bool HasScenes() => GetRelatedScenes().Count > 0;
///
/// Returns a collection of valid scenes found in the associated Timeline.
/// It looks for Scene Activation Tracks with a valid reference to a scene.
///
///
IReadOnlyCollection GetScenes()
{
if (IsNullOrEmpty(this))
return new List();
return timeline.GetScenes();
}
///
/// Gets all the scenes needed to have the scene context for this clip complete. This includes all upstream,
/// downstream scenes and the scenes of the clip itself.
///
/// A collection of Scene paths.
/// The returned paths are ordered from upstream to downstream.
internal IReadOnlyCollection GetRelatedScenes()
{
List paths = new List();
// Get ascendant scenes
if (parent != null)
paths.AddRange((parent as TimelineSequence).GetAscendantScenes());
// Add local scenes
paths.AddRange(GetScenes());
// Append descendant scenes
foreach (var child in children)
paths.AddRange((child as TimelineSequence).GetDescendantScenes());
return paths;
}
///
/// Iterates through all clip parents and gets the Scene paths found in their respective timeline.
/// It also includes the Scene paths from the given clip.
///
///
///
IReadOnlyCollection GetAscendantScenes()
{
List paths = new List();
if (parent != null)
paths.AddRange((parent as TimelineSequence).GetAscendantScenes());
paths.AddRange(GetScenes());
return paths;
}
///
/// Iterates through all clip children and gets the Scene paths found in their respective timeline.
/// It also includes the Scene paths from the given clip.
///
///
///
IReadOnlyCollection GetDescendantScenes()
{
List paths = new List();
paths.AddRange(GetScenes());
foreach (var child in children)
paths.AddRange((child as TimelineSequence).GetDescendantScenes());
return paths;
}
}
}