Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,23 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
enum TrimEdge
|
||||
{
|
||||
Start,
|
||||
End
|
||||
}
|
||||
|
||||
interface ITrimItemMode
|
||||
{
|
||||
void OnBeforeTrim(ITrimmable item, TrimEdge trimDirection);
|
||||
|
||||
void TrimStart(ITrimmable item, double time, bool affectTimeScale);
|
||||
void TrimEnd(ITrimmable item, double time, bool affectTimeScale);
|
||||
}
|
||||
|
||||
interface ITrimItemDrawer
|
||||
{
|
||||
void DrawGUI(WindowState state, Rect bounds, Color color, TrimEdge edge);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b4a5ce78107bc38409a3bb5e8b3289ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,102 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
class TrimItemModeMix : ITrimItemMode, ITrimItemDrawer
|
||||
{
|
||||
ITrimmable m_Item;
|
||||
|
||||
double m_Min;
|
||||
double m_Max;
|
||||
|
||||
public void OnBeforeTrim(ITrimmable item, TrimEdge trimDirection)
|
||||
{
|
||||
m_Item = item;
|
||||
|
||||
var sortedItems = ItemsUtils.GetItemsExcept(item.parentTrack, new[] {item})
|
||||
.OfType<ITrimmable>()
|
||||
.OrderBy(c => c.start);
|
||||
|
||||
var itemStart = (DiscreteTime)item.start;
|
||||
var itemEnd = (DiscreteTime)item.end;
|
||||
|
||||
var overlapped = sortedItems.LastOrDefault(c => (DiscreteTime)c.start == itemStart && (DiscreteTime)c.end == itemEnd);
|
||||
|
||||
ITrimmable nextItem;
|
||||
ITrimmable prevItem;
|
||||
|
||||
m_Min = 0.0;
|
||||
m_Max = double.PositiveInfinity;
|
||||
|
||||
var blendableItem = item as IBlendable;
|
||||
if (blendableItem != null && blendableItem.supportsBlending)
|
||||
{
|
||||
if (trimDirection == TrimEdge.Start)
|
||||
{
|
||||
nextItem = sortedItems.FirstOrDefault(c => (DiscreteTime)c.start >= itemStart && (DiscreteTime)c.end > itemEnd);
|
||||
prevItem = sortedItems.LastOrDefault(c => (DiscreteTime)c.start <= itemStart && (DiscreteTime)c.end < itemEnd);
|
||||
|
||||
if (prevItem != null)
|
||||
m_Min = prevItem.start + EditModeUtils.BlendDuration(prevItem, TrimEdge.Start);
|
||||
|
||||
if (nextItem != null)
|
||||
m_Max = nextItem.start;
|
||||
}
|
||||
else
|
||||
{
|
||||
nextItem = sortedItems.FirstOrDefault(c => c != overlapped && (DiscreteTime)c.start >= itemStart && (DiscreteTime)c.end >= itemEnd);
|
||||
prevItem = sortedItems.LastOrDefault(c => c != overlapped && (DiscreteTime)c.start <= itemStart && (DiscreteTime)c.end <= itemEnd);
|
||||
|
||||
if (prevItem != null)
|
||||
m_Min = prevItem.end;
|
||||
|
||||
if (nextItem != null)
|
||||
m_Max = nextItem.end - EditModeUtils.BlendDuration(nextItem, TrimEdge.End);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nextItem = sortedItems.FirstOrDefault(c => (DiscreteTime)c.start > itemStart);
|
||||
prevItem = sortedItems.LastOrDefault(c => (DiscreteTime)c.start < itemStart);
|
||||
|
||||
if (prevItem != null)
|
||||
m_Min = prevItem.end;
|
||||
|
||||
if (nextItem != null)
|
||||
m_Max = nextItem.start;
|
||||
}
|
||||
}
|
||||
|
||||
public void TrimStart(ITrimmable item, double time, bool affectTimeScale)
|
||||
{
|
||||
time = Math.Min(Math.Max(time, m_Min), m_Max);
|
||||
item.SetStart(time, affectTimeScale);
|
||||
}
|
||||
|
||||
public void TrimEnd(ITrimmable item, double time, bool affectTimeScale)
|
||||
{
|
||||
time = Math.Min(Math.Max(time, m_Min), m_Max);
|
||||
item.SetEnd(time, affectTimeScale);
|
||||
}
|
||||
|
||||
public void DrawGUI(WindowState state, Rect bounds, Color color, TrimEdge edge)
|
||||
{
|
||||
if (EditModeUtils.HasBlends(m_Item, edge))
|
||||
{
|
||||
EditModeGUIUtils.DrawBoundsEdge(bounds, color, edge);
|
||||
var cursorType = (edge == TrimEdge.End)
|
||||
? TimelineCursors.CursorType.MixRight
|
||||
: TimelineCursors.CursorType.MixLeft;
|
||||
|
||||
TimelineCursors.SetCursor(cursorType);
|
||||
}
|
||||
else
|
||||
{
|
||||
TimelineCursors.ClearCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5ddd9f7d3cce6724696a33752ab2f5a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,139 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
class TrimItemModeReplace : ITrimItemMode, ITrimItemDrawer
|
||||
{
|
||||
ITrimmable m_Item;
|
||||
|
||||
ITrimmable m_ItemToBeReplaced;
|
||||
double m_ClipOriginalEdgeValue;
|
||||
bool m_TrimReplace;
|
||||
|
||||
double m_Min;
|
||||
double m_Max;
|
||||
|
||||
public void OnBeforeTrim(ITrimmable item, TrimEdge trimDirection)
|
||||
{
|
||||
m_Item = item;
|
||||
|
||||
var sortedClips = ItemsUtils.GetItemsExcept(item.parentTrack, new[] { item })
|
||||
.OfType<ITrimmable>()
|
||||
.OrderBy(c => c.start);
|
||||
|
||||
var clipStart = (DiscreteTime)item.start;
|
||||
var clipEnd = (DiscreteTime)item.end;
|
||||
|
||||
var overlapped = sortedClips.LastOrDefault(c => (DiscreteTime)c.start == clipStart && (DiscreteTime)c.end == clipEnd);
|
||||
|
||||
ITrimmable nextItem;
|
||||
ITrimmable prevItem;
|
||||
|
||||
m_Min = 0.0;
|
||||
m_Max = double.PositiveInfinity;
|
||||
|
||||
if (trimDirection == TrimEdge.Start)
|
||||
{
|
||||
nextItem = sortedClips.FirstOrDefault(c => (DiscreteTime)c.start >= clipStart && (DiscreteTime)c.end > clipEnd);
|
||||
prevItem = sortedClips.LastOrDefault(c => (DiscreteTime)c.start <= clipStart && (DiscreteTime)c.end < clipEnd);
|
||||
|
||||
if (prevItem != null)
|
||||
m_Min = prevItem.start + EditModeUtils.BlendDuration(prevItem, TrimEdge.Start) + TimelineClip.kMinDuration;
|
||||
|
||||
if (nextItem != null)
|
||||
m_Max = nextItem.start;
|
||||
|
||||
m_ItemToBeReplaced = prevItem;
|
||||
|
||||
if (m_ItemToBeReplaced != null)
|
||||
m_ClipOriginalEdgeValue = m_ItemToBeReplaced.end;
|
||||
}
|
||||
else
|
||||
{
|
||||
nextItem = sortedClips.FirstOrDefault(c => c != overlapped && (DiscreteTime)c.start >= clipStart && (DiscreteTime)c.end >= clipEnd);
|
||||
prevItem = sortedClips.LastOrDefault(c => c != overlapped && (DiscreteTime)c.start <= clipStart && (DiscreteTime)c.end <= clipEnd);
|
||||
|
||||
if (prevItem != null)
|
||||
m_Min = prevItem.end;
|
||||
|
||||
if (nextItem != null)
|
||||
m_Max = nextItem.end - EditModeUtils.BlendDuration(nextItem, TrimEdge.End) - TimelineClip.kMinDuration;
|
||||
|
||||
m_ItemToBeReplaced = nextItem;
|
||||
|
||||
if (m_ItemToBeReplaced != null)
|
||||
m_ClipOriginalEdgeValue = m_ItemToBeReplaced.start;
|
||||
}
|
||||
|
||||
m_TrimReplace = false;
|
||||
}
|
||||
|
||||
public void TrimStart(ITrimmable item, double time, bool affectTimeScale)
|
||||
{
|
||||
time = Math.Min(Math.Max(time, m_Min), m_Max);
|
||||
|
||||
if (m_ItemToBeReplaced != null)
|
||||
{
|
||||
if (!m_TrimReplace)
|
||||
m_TrimReplace = item.start >= m_ItemToBeReplaced.end;
|
||||
}
|
||||
|
||||
time = Math.Max(time, 0.0);
|
||||
|
||||
item.SetStart(time, affectTimeScale);
|
||||
|
||||
if (m_ItemToBeReplaced != null && m_TrimReplace)
|
||||
{
|
||||
var prevEnd = Math.Min(item.start, m_ClipOriginalEdgeValue);
|
||||
m_ItemToBeReplaced.SetEnd(prevEnd, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void TrimEnd(ITrimmable item, double time, bool affectTimeScale)
|
||||
{
|
||||
time = Math.Min(Math.Max(time, m_Min), m_Max);
|
||||
|
||||
if (m_ItemToBeReplaced != null)
|
||||
{
|
||||
if (!m_TrimReplace)
|
||||
m_TrimReplace = item.end <= m_ItemToBeReplaced.start;
|
||||
}
|
||||
|
||||
item.SetEnd(time, affectTimeScale);
|
||||
|
||||
if (m_ItemToBeReplaced != null && m_TrimReplace)
|
||||
{
|
||||
var nextStart = Math.Max(item.end, m_ClipOriginalEdgeValue);
|
||||
m_ItemToBeReplaced.SetStart(nextStart, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawGUI(WindowState state, Rect bounds, Color color, TrimEdge edge)
|
||||
{
|
||||
bool shouldDraw = m_ItemToBeReplaced != null && (edge == TrimEdge.End && m_Item.end > m_ClipOriginalEdgeValue) ||
|
||||
(edge == TrimEdge.Start && m_Item.start < m_ClipOriginalEdgeValue);
|
||||
|
||||
if (shouldDraw)
|
||||
{
|
||||
var cursorType = TimelineCursors.CursorType.Replace;
|
||||
if (EditModeUtils.HasBlends(m_Item, edge))
|
||||
{
|
||||
color = DirectorStyles.kMixToolColor;
|
||||
cursorType = (edge == TrimEdge.End)
|
||||
? TimelineCursors.CursorType.MixRight
|
||||
: TimelineCursors.CursorType.MixLeft;
|
||||
}
|
||||
|
||||
EditModeGUIUtils.DrawBoundsEdge(bounds, color, edge);
|
||||
TimelineCursors.SetCursor(cursorType);
|
||||
}
|
||||
else
|
||||
{
|
||||
TimelineCursors.ClearCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 769f6f5dd7c8f2d4c9ab1caba0bd2628
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,97 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Timeline;
|
||||
|
||||
namespace UnityEditor.Timeline
|
||||
{
|
||||
class TrimItemModeRipple : ITrimItemMode, ITrimItemDrawer
|
||||
{
|
||||
double m_OriginalClipStart;
|
||||
double m_OriginalClipEnd;
|
||||
|
||||
ITrimmable[] m_NextItems;
|
||||
|
||||
double m_BlendDuration;
|
||||
|
||||
double m_TrimStartShift;
|
||||
|
||||
public void OnBeforeTrim(ITrimmable item, TrimEdge trimDirection)
|
||||
{
|
||||
m_OriginalClipStart = item.start;
|
||||
m_OriginalClipEnd = item.end;
|
||||
m_TrimStartShift = 0.0;
|
||||
|
||||
var sortedClips = ItemsUtils.GetItemsExcept(item.parentTrack, new[] { item })
|
||||
.OfType<ITrimmable>()
|
||||
.OrderBy(c => c.start);
|
||||
|
||||
var clipStart = (DiscreteTime)item.start;
|
||||
var clipEnd = (DiscreteTime)item.end;
|
||||
|
||||
m_NextItems = sortedClips.Where(c => (DiscreteTime)c.start >= clipStart && (DiscreteTime)c.end >= clipEnd).ToArray();
|
||||
|
||||
var overlapped = sortedClips.LastOrDefault(c => (DiscreteTime)c.start == clipStart && (DiscreteTime)c.end == clipEnd);
|
||||
|
||||
if (overlapped != null)
|
||||
{
|
||||
m_BlendDuration = overlapped.end - overlapped.start;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BlendDuration = 0.0;
|
||||
|
||||
var prevClip = sortedClips.LastOrDefault(c => (DiscreteTime)c.start <= clipStart && (DiscreteTime)c.end <= clipEnd);
|
||||
if (prevClip != null)
|
||||
m_BlendDuration += Math.Max(prevClip.end - item.start, 0.0);
|
||||
|
||||
var nextClip = sortedClips.FirstOrDefault(c => (DiscreteTime)c.start >= clipStart && (DiscreteTime)c.end >= clipEnd);
|
||||
if (nextClip != null)
|
||||
m_BlendDuration += Math.Max(item.end - nextClip.start, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
public void TrimStart(ITrimmable item, double time, bool affectTimeScale)
|
||||
{
|
||||
var prevEnd = item.end;
|
||||
|
||||
// HACK If time is negative, make sure we shift the SetStart operation to a positive space.
|
||||
if (time < 0.0)
|
||||
m_TrimStartShift = Math.Max(-time, m_TrimStartShift);
|
||||
|
||||
item.start = m_OriginalClipEnd - item.duration + m_TrimStartShift;
|
||||
time += m_TrimStartShift;
|
||||
|
||||
if (m_BlendDuration > 0.0)
|
||||
time = Math.Min(time, item.end - m_BlendDuration);
|
||||
|
||||
item.SetStart(time, affectTimeScale);
|
||||
|
||||
item.start = m_OriginalClipStart;
|
||||
|
||||
var offset = item.end - prevEnd;
|
||||
foreach (var timelineClip in m_NextItems)
|
||||
timelineClip.start += offset;
|
||||
}
|
||||
|
||||
public void TrimEnd(ITrimmable item, double time, bool affectTimeScale)
|
||||
{
|
||||
var prevEnd = item.end;
|
||||
|
||||
if (m_BlendDuration > 0.0)
|
||||
time = Math.Max(time, item.start + m_BlendDuration);
|
||||
|
||||
item.SetEnd(time, affectTimeScale);
|
||||
|
||||
var offset = item.end - prevEnd;
|
||||
foreach (var timelineClip in m_NextItems)
|
||||
timelineClip.start += offset;
|
||||
}
|
||||
|
||||
public void DrawGUI(WindowState state, Rect bounds, Color color, TrimEdge edge)
|
||||
{
|
||||
EditModeGUIUtils.DrawBoundsEdge(bounds, color, edge);
|
||||
TimelineCursors.SetCursor(TimelineCursors.CursorType.Ripple);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 20c8bb6b47a526c4c96ca73314fe2856
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue