2022-01-13 03:59:54 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
2022-01-16 22:51:57 +00:00
|
|
|
using System.Linq;
|
2022-01-13 03:59:54 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
using HeavenStudio.Editor.Track;
|
2022-01-28 02:50:57 +00:00
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
namespace HeavenStudio.Editor
|
2022-01-13 03:59:54 +00:00
|
|
|
{
|
|
|
|
public class Selections : MonoBehaviour
|
|
|
|
{
|
|
|
|
public List<TimelineEventObj> eventsSelected = new List<TimelineEventObj>();
|
|
|
|
|
|
|
|
public static Selections instance { get; private set; }
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
instance = this;
|
|
|
|
}
|
|
|
|
|
2022-01-16 22:51:57 +00:00
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
var buggedSelections = eventsSelected.FindAll(c => c == null);
|
|
|
|
if (buggedSelections.Count > 0)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < buggedSelections.Count; i++)
|
2023-04-29 22:51:25 +00:00
|
|
|
Deselect(buggedSelections[i]);
|
|
|
|
}
|
|
|
|
if (Editor.instance.isShortcutsEnabled)
|
|
|
|
{
|
|
|
|
if (Input.GetKey(KeyCode.LeftControl))
|
|
|
|
if (Input.GetKeyDown(KeyCode.A))
|
|
|
|
SelectAll();
|
2022-01-16 22:51:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-13 03:59:54 +00:00
|
|
|
public void ClickSelect(TimelineEventObj eventToAdd)
|
|
|
|
{
|
|
|
|
DeselectAll();
|
|
|
|
eventsSelected.Add(eventToAdd);
|
2022-01-23 03:40:53 +00:00
|
|
|
|
|
|
|
// CommandManager.instance.Execute(new Commands.Selection(new List<TimelineEventObj>() { eventToAdd } ));
|
2022-01-13 03:59:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void ShiftClickSelect(TimelineEventObj eventToAdd)
|
|
|
|
{
|
|
|
|
if (!eventsSelected.Contains(eventToAdd))
|
|
|
|
{
|
|
|
|
eventsSelected.Add(eventToAdd);
|
|
|
|
}
|
2022-01-17 23:54:25 +00:00
|
|
|
else
|
2022-01-13 03:59:54 +00:00
|
|
|
{
|
|
|
|
eventsSelected.Remove(eventToAdd);
|
2022-01-17 23:54:25 +00:00
|
|
|
}
|
2022-01-13 03:59:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void DragSelect(TimelineEventObj eventToAdd)
|
|
|
|
{
|
|
|
|
if (!eventsSelected.Contains(eventToAdd))
|
|
|
|
{
|
|
|
|
eventsSelected.Add(eventToAdd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-05 19:48:49 +00:00
|
|
|
public void SelectAll()
|
|
|
|
{
|
|
|
|
DeselectAll();
|
|
|
|
var eventObjs = Timeline.instance.eventObjs;
|
|
|
|
for (int i = 0; i < eventObjs.Count; i++)
|
|
|
|
eventsSelected.Add(eventObjs[i]);
|
|
|
|
}
|
|
|
|
|
2022-01-13 03:59:54 +00:00
|
|
|
public void DeselectAll()
|
|
|
|
{
|
|
|
|
eventsSelected.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Deselect(TimelineEventObj eventToDeselect)
|
|
|
|
{
|
|
|
|
if (eventsSelected.Contains(eventToDeselect))
|
|
|
|
{
|
|
|
|
eventsSelected.Remove(eventToDeselect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|