PickerUtils.cs
1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace UnityEditor.Timeline
{
static class PickerUtils
{
public static List<object> pickedElements { get; private set; }
public static void DoPick(WindowState state, Vector2 mousePosition)
{
if (state.GetWindow().sequenceContentRect.Contains(mousePosition))
{
pickedElements = state.spacePartitioner.GetItemsAtPosition<object>(mousePosition).ToList();
}
else
{
if (pickedElements != null)
pickedElements.Clear();
else
pickedElements = new List<object>();
}
}
public static T PickedLayerableOfType<T>() where T : class, ILayerable
{
return pickedElements.OfType<ILayerable>().OrderBy(x => x.zOrder).LastOrDefault() as T;
}
public static InlineCurveResizeHandle PickedInlineCurveResizer()
{
return pickedElements.FirstOrDefault(e => e is InlineCurveResizeHandle) as InlineCurveResizeHandle;
}
public static TimelineTrackBaseGUI PickedTrackBaseGUI()
{
return pickedElements.FirstOrDefault(e => e is TimelineTrackBaseGUI) as TimelineTrackBaseGUI;
}
}
}