From c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 19 Apr 2020 17:19:32 -0400 Subject: Inital commit --- .../ControlTrack/ControlPlayableAssetEditor.cs | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Library/PackageCache/com.unity.timeline@1.2.13/Editor/ControlTrack/ControlPlayableAssetEditor.cs (limited to 'Library/PackageCache/com.unity.timeline@1.2.13/Editor/ControlTrack/ControlPlayableAssetEditor.cs') diff --git a/Library/PackageCache/com.unity.timeline@1.2.13/Editor/ControlTrack/ControlPlayableAssetEditor.cs b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/ControlTrack/ControlPlayableAssetEditor.cs new file mode 100644 index 0000000..066e943 --- /dev/null +++ b/Library/PackageCache/com.unity.timeline@1.2.13/Editor/ControlTrack/ControlPlayableAssetEditor.cs @@ -0,0 +1,69 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Timeline; +using UnityEngine.Playables; + +namespace UnityEditor.Timeline +{ + [CustomTimelineEditor(typeof(ControlPlayableAsset))] + class ControlPlayableAssetEditor : ClipEditor + { + static readonly Texture2D[] s_ParticleSystemIcon = {AssetPreview.GetMiniTypeThumbnail(typeof(ParticleSystem))}; + + public override ClipDrawOptions GetClipOptions(TimelineClip clip) + { + var asset = (ControlPlayableAsset)clip.asset; + var options = base.GetClipOptions(clip); + if (asset.updateParticle && TimelineEditor.inspectedDirector != null && asset.controllingParticles) + options.icons = s_ParticleSystemIcon; + return options; + } + + public override void OnCreate(TimelineClip clip, TrackAsset track, TimelineClip clonedFrom) + { + var asset = (ControlPlayableAsset)clip.asset; + GameObject sourceObject = null; + + // go by sourceObject first, then by prefab + if (TimelineEditor.inspectedDirector != null) + sourceObject = asset.sourceGameObject.Resolve(TimelineEditor.inspectedDirector); + + if (sourceObject == null && asset.prefabGameObject != null) + sourceObject = asset.prefabGameObject; + + if (sourceObject) + { + var directors = asset.GetComponent(sourceObject); + var particleSystems = asset.GetComponent(sourceObject); + + // update the duration and loop values (used for UI purposes) here + // so they are tied to the latest gameObject bound + asset.UpdateDurationAndLoopFlag(directors, particleSystems); + + clip.displayName = sourceObject.name; + } + } + + public override void GetSubTimelines(TimelineClip clip, PlayableDirector director, List subTimelines) + { + var asset = (ControlPlayableAsset)clip.asset; + + // If there is a prefab, it will override the source GameObject + if (!asset.updateDirector || asset.prefabGameObject != null || director == null) + return; + + var go = asset.sourceGameObject.Resolve(director); + if (go == null) + return; + + foreach (var subTimeline in asset.GetComponent(go)) + { + if (subTimeline == director || subTimeline == TimelineEditor.masterDirector || subTimeline == TimelineEditor.inspectedDirector) + continue; + + if (subTimeline.playableAsset is TimelineAsset) + subTimelines.Add(subTimeline); + } + } + } +} -- cgit v1.2.3