Unity-jump-proj
This commit is contained in:
@ -0,0 +1,145 @@
|
||||
using System;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
class ClipItem : IBlendable, ITrimmable
|
||||
{
|
||||
readonly TimelineClip m_Clip;
|
||||
|
||||
public TimelineClip clip
|
||||
{
|
||||
get { return m_Clip; }
|
||||
}
|
||||
|
||||
public ClipItem(TimelineClip clip)
|
||||
{
|
||||
m_Clip = clip;
|
||||
}
|
||||
|
||||
public TrackAsset parentTrack
|
||||
{
|
||||
get { return m_Clip.GetParentTrack(); }
|
||||
set { m_Clip.SetParentTrack_Internal(value); }
|
||||
}
|
||||
|
||||
public double start
|
||||
{
|
||||
get { return m_Clip.start; }
|
||||
set { m_Clip.start = value; }
|
||||
}
|
||||
|
||||
public double end
|
||||
{
|
||||
get { return m_Clip.end; }
|
||||
}
|
||||
|
||||
public double duration
|
||||
{
|
||||
get { return m_Clip.duration; }
|
||||
}
|
||||
|
||||
public bool IsCompatibleWithTrack(TrackAsset track)
|
||||
{
|
||||
return track.IsCompatibleWithClip(m_Clip);
|
||||
}
|
||||
|
||||
public void PushUndo(string operation)
|
||||
{
|
||||
UndoExtensions.RegisterClip(m_Clip, operation);
|
||||
}
|
||||
|
||||
public TimelineItemGUI gui
|
||||
{
|
||||
get { return ItemToItemGui.GetGuiForClip(m_Clip); }
|
||||
}
|
||||
|
||||
public bool supportsBlending
|
||||
{
|
||||
get { return m_Clip.SupportsBlending(); }
|
||||
}
|
||||
|
||||
public bool hasLeftBlend
|
||||
{
|
||||
get { return m_Clip.hasBlendIn; }
|
||||
}
|
||||
|
||||
public bool hasRightBlend
|
||||
{
|
||||
get { return m_Clip.hasBlendOut; }
|
||||
}
|
||||
|
||||
public double leftBlendDuration
|
||||
{
|
||||
get { return m_Clip.hasBlendIn ? m_Clip.blendInDuration : m_Clip.easeInDuration; }
|
||||
}
|
||||
|
||||
public double rightBlendDuration
|
||||
{
|
||||
get { return m_Clip.hasBlendOut ? m_Clip.blendOutDuration : m_Clip.easeOutDuration; }
|
||||
}
|
||||
|
||||
public void SetStart(double time, bool affectTimeScale)
|
||||
{
|
||||
ClipModifier.SetStart(m_Clip, time, affectTimeScale);
|
||||
m_Clip.ConformEaseValues();
|
||||
}
|
||||
|
||||
public void SetEnd(double time, bool affectTimeScale)
|
||||
{
|
||||
ClipModifier.SetEnd(m_Clip, time, affectTimeScale);
|
||||
m_Clip.ConformEaseValues();
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
EditorClipFactory.RemoveEditorClip(m_Clip);
|
||||
ClipModifier.Delete(m_Clip.GetParentTrack().timelineAsset, m_Clip);
|
||||
}
|
||||
|
||||
public void TrimStart(double time)
|
||||
{
|
||||
ClipModifier.TrimStart(m_Clip, time);
|
||||
}
|
||||
|
||||
public void TrimEnd(double time)
|
||||
{
|
||||
ClipModifier.TrimEnd(m_Clip, time);
|
||||
}
|
||||
|
||||
public ITimelineItem CloneTo(TrackAsset parent, double time)
|
||||
{
|
||||
return new ClipItem(TimelineHelpers.Clone(m_Clip, TimelineEditor.inspectedDirector, TimelineEditor.inspectedDirector, time, parent));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return m_Clip.ToString();
|
||||
}
|
||||
|
||||
public bool Equals(ClipItem otherClip)
|
||||
{
|
||||
if (ReferenceEquals(null, otherClip)) return false;
|
||||
if (ReferenceEquals(this, otherClip)) return true;
|
||||
return Equals(m_Clip, otherClip.m_Clip);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (m_Clip != null ? m_Clip.GetHashCode() : 0);
|
||||
}
|
||||
|
||||
public bool Equals(ITimelineItem other)
|
||||
{
|
||||
return Equals((object)other);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
var other = obj as ClipItem;
|
||||
return other != null && Equals(other);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d143f3edd0494bc4c98a421bd59564fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
interface ITimelineItem : IEquatable<ITimelineItem>
|
||||
{
|
||||
double start { get; set; }
|
||||
double end { get; }
|
||||
double duration { get; }
|
||||
|
||||
TrackAsset parentTrack { get; set; }
|
||||
bool IsCompatibleWithTrack(TrackAsset track);
|
||||
|
||||
void Delete();
|
||||
ITimelineItem CloneTo(TrackAsset parent, double time);
|
||||
void PushUndo(string operation);
|
||||
|
||||
TimelineItemGUI gui { get; }
|
||||
}
|
||||
|
||||
interface ITrimmable : ITimelineItem
|
||||
{
|
||||
void SetStart(double time, bool affectTimeScale);
|
||||
void SetEnd(double time, bool affectTimeScale);
|
||||
void TrimStart(double time);
|
||||
void TrimEnd(double time);
|
||||
}
|
||||
|
||||
interface IBlendable : ITimelineItem
|
||||
{
|
||||
bool supportsBlending { get; }
|
||||
bool hasLeftBlend { get; }
|
||||
bool hasRightBlend { get; }
|
||||
|
||||
double leftBlendDuration { get; }
|
||||
double rightBlendDuration { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c87ec8c97244cd47945ec90a99abe35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
class ItemsGroup
|
||||
{
|
||||
readonly ITimelineItem[] m_Items;
|
||||
readonly ITimelineItem m_LeftMostItem;
|
||||
readonly ITimelineItem m_RightMostItem;
|
||||
|
||||
public ITimelineItem[] items
|
||||
{
|
||||
get { return m_Items; }
|
||||
}
|
||||
|
||||
public double start
|
||||
{
|
||||
get { return m_LeftMostItem.start; }
|
||||
set
|
||||
{
|
||||
var offset = value - m_LeftMostItem.start;
|
||||
|
||||
foreach (var clip in m_Items)
|
||||
clip.start += offset;
|
||||
}
|
||||
}
|
||||
|
||||
public double end
|
||||
{
|
||||
get { return m_RightMostItem.end; }
|
||||
}
|
||||
|
||||
public ITimelineItem leftMostItem
|
||||
{
|
||||
get { return m_LeftMostItem; }
|
||||
}
|
||||
|
||||
public ITimelineItem rightMostItem
|
||||
{
|
||||
get { return m_RightMostItem; }
|
||||
}
|
||||
|
||||
public ItemsGroup(IEnumerable<ITimelineItem> items)
|
||||
{
|
||||
Debug.Assert(items != null && items.Any());
|
||||
|
||||
m_Items = items.ToArray();
|
||||
m_LeftMostItem = null;
|
||||
m_RightMostItem = null;
|
||||
|
||||
foreach (var item in m_Items)
|
||||
{
|
||||
if (m_LeftMostItem == null || item.start < m_LeftMostItem.start)
|
||||
m_LeftMostItem = item;
|
||||
|
||||
if (m_RightMostItem == null || item.end > m_RightMostItem.end)
|
||||
m_RightMostItem = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ec4b8ec4b34f4344bac53c19288eaa2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
class ItemsPerTrack
|
||||
{
|
||||
public virtual TrackAsset targetTrack { get; }
|
||||
|
||||
public IEnumerable<ITimelineItem> items
|
||||
{
|
||||
get { return m_ItemsGroup.items; }
|
||||
}
|
||||
|
||||
public IEnumerable<TimelineClip> clips
|
||||
{
|
||||
get { return m_ItemsGroup.items.OfType<ClipItem>().Select(i => i.clip); }
|
||||
}
|
||||
|
||||
public IEnumerable<IMarker> markers
|
||||
{
|
||||
get { return m_ItemsGroup.items.OfType<MarkerItem>().Select(i => i.marker); }
|
||||
}
|
||||
|
||||
public ITimelineItem leftMostItem
|
||||
{
|
||||
get { return m_ItemsGroup.leftMostItem; }
|
||||
}
|
||||
|
||||
public ITimelineItem rightMostItem
|
||||
{
|
||||
get { return m_ItemsGroup.rightMostItem; }
|
||||
}
|
||||
|
||||
protected readonly ItemsGroup m_ItemsGroup;
|
||||
|
||||
public ItemsPerTrack(TrackAsset targetTrack, IEnumerable<ITimelineItem> items)
|
||||
{
|
||||
this.targetTrack = targetTrack;
|
||||
m_ItemsGroup = new ItemsGroup(items);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 647e1bbd3809b30459d946b4a1ddf22b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,116 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
static class ItemsUtils
|
||||
{
|
||||
static readonly Dictionary<TimelineClip, ClipItem> s_ClipCache = new Dictionary<TimelineClip, ClipItem>();
|
||||
static readonly Dictionary<IMarker, MarkerItem> s_MarkerCache = new Dictionary<IMarker, MarkerItem>();
|
||||
|
||||
public static IEnumerable<ItemsPerTrack> ToItemsPerTrack(this IEnumerable<ITimelineItem> items)
|
||||
{
|
||||
var groupedItems = items.GroupBy(c => c.parentTrack);
|
||||
foreach (var group in groupedItems)
|
||||
{
|
||||
yield return new ItemsPerTrack(group.Key, group.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
public static ITimelineItem ToItem(this TimelineClip clip)
|
||||
{
|
||||
if (s_ClipCache.ContainsKey(clip))
|
||||
return s_ClipCache[clip];
|
||||
|
||||
var ret = new ClipItem(clip);
|
||||
s_ClipCache.Add(clip, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ITimelineItem ToItem(this IMarker marker)
|
||||
{
|
||||
if (s_MarkerCache.ContainsKey(marker))
|
||||
return s_MarkerCache[marker];
|
||||
|
||||
var ret = new MarkerItem(marker);
|
||||
s_MarkerCache.Add(marker, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static IEnumerable<ITimelineItem> ToItems(this IEnumerable<TimelineClip> clips)
|
||||
{
|
||||
return clips.Select(ToItem);
|
||||
}
|
||||
|
||||
public static IEnumerable<ITimelineItem> ToItems(this IEnumerable<IMarker> markers)
|
||||
{
|
||||
return markers.Select(ToItem);
|
||||
}
|
||||
|
||||
public static IEnumerable<ITimelineItem> GetItems(this TrackAsset track)
|
||||
{
|
||||
var list = track.clips.Select(clip => (ITimelineItem)new ClipItem(clip)).ToList();
|
||||
list.AddRange(track.GetMarkers().Select(marker => (ITimelineItem)new MarkerItem(marker)));
|
||||
|
||||
list = list.OrderBy(x => x.start).ThenBy(x => x.end).ToList();
|
||||
return list;
|
||||
}
|
||||
|
||||
public static void GetItemRange(this TrackAsset track, out double start, out double end)
|
||||
{
|
||||
start = 0;
|
||||
end = 0;
|
||||
var items = track.GetItems().ToList();
|
||||
if (items.Any())
|
||||
{
|
||||
start = items.Min(p => p.start);
|
||||
end = items.Max(p => p.end);
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<ITimelineItem> GetItemsExcept(this TrackAsset track, IEnumerable<ITimelineItem> items)
|
||||
{
|
||||
return GetItems(track).Except(items);
|
||||
}
|
||||
|
||||
public static IEnumerable<Type> GetItemTypes(IEnumerable<ITimelineItem> items)
|
||||
{
|
||||
var types = new List<Type>();
|
||||
if (items.OfType<ClipItem>().Any())
|
||||
types.Add(typeof(ClipItem));
|
||||
if (items.OfType<MarkerItem>().Any())
|
||||
types.Add(typeof(MarkerItem));
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
public static IEnumerable<Type> GetItemTypes(IEnumerable<ItemsPerTrack> itemsGroups)
|
||||
{
|
||||
return GetItemTypes(itemsGroups.SelectMany(i => i.items)).Distinct();
|
||||
}
|
||||
|
||||
public static void SetItemsStartTime(IEnumerable<ItemsPerTrack> newItems, double time)
|
||||
{
|
||||
var startTimes = newItems.Select(d => d.items.Min(x => x.start)).ToList();
|
||||
var min = startTimes.Min();
|
||||
startTimes = startTimes.Select(x => x - min + time).ToList();
|
||||
|
||||
for (int i = 0; i < newItems.Count(); ++i)
|
||||
EditModeUtils.SetStart(newItems.ElementAt(i).items, startTimes[i]);
|
||||
}
|
||||
|
||||
public static double TimeGapBetweenItems(ITimelineItem leftItem, ITimelineItem rightItem)
|
||||
{
|
||||
if (leftItem is MarkerItem && rightItem is MarkerItem)
|
||||
{
|
||||
var markerType = ((MarkerItem)leftItem).marker.GetType();
|
||||
var gap = TimeReferenceUtility.PixelToTime(StyleManager.UssStyleForType(markerType).fixedWidth) - TimeReferenceUtility.PixelToTime(0);
|
||||
return gap;
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5653477a5039f674da8f856adcf47172
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using UnityEngine.Timeline;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
class MarkerItem : ITimelineItem
|
||||
{
|
||||
readonly IMarker m_Marker;
|
||||
|
||||
public IMarker marker
|
||||
{
|
||||
get { return m_Marker; }
|
||||
}
|
||||
|
||||
public MarkerItem(IMarker marker)
|
||||
{
|
||||
m_Marker = marker;
|
||||
}
|
||||
|
||||
public TrackAsset parentTrack
|
||||
{
|
||||
get { return m_Marker.parent; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public double start
|
||||
{
|
||||
get { return m_Marker.time; }
|
||||
set { m_Marker.time = value; }
|
||||
}
|
||||
|
||||
public double end
|
||||
{
|
||||
get { return m_Marker.time; }
|
||||
}
|
||||
|
||||
public double duration
|
||||
{
|
||||
get { return 0.0; }
|
||||
}
|
||||
|
||||
public bool IsCompatibleWithTrack(TrackAsset track)
|
||||
{
|
||||
return TypeUtility.DoesTrackSupportMarkerType(track, m_Marker.GetType());
|
||||
}
|
||||
|
||||
public void PushUndo(string operation)
|
||||
{
|
||||
UndoExtensions.RegisterMarker(m_Marker, operation);
|
||||
}
|
||||
|
||||
public TimelineItemGUI gui
|
||||
{
|
||||
get { return ItemToItemGui.GetGuiForMarker(m_Marker); }
|
||||
}
|
||||
|
||||
public void Delete()
|
||||
{
|
||||
MarkerModifier.DeleteMarker(m_Marker);
|
||||
}
|
||||
|
||||
public ITimelineItem CloneTo(TrackAsset parent, double time)
|
||||
{
|
||||
var item = new MarkerItem(MarkerModifier.CloneMarkerToParent(m_Marker, parent));
|
||||
item.start = time;
|
||||
return item;
|
||||
}
|
||||
|
||||
protected bool Equals(MarkerItem otherMarker)
|
||||
{
|
||||
return Equals(m_Marker, otherMarker.m_Marker);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (m_Marker != null ? m_Marker.GetHashCode() : 0);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return m_Marker.ToString();
|
||||
}
|
||||
|
||||
public bool Equals(ITimelineItem other)
|
||||
{
|
||||
return Equals((object)other);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
var other = obj as MarkerItem;
|
||||
return other != null && Equals(other);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 452534715106564439d2240d82999d88
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user