HeavenStudio/Assets/Scripts/LevelEditor/Selections.cs

72 lines
1.8 KiB
C#
Raw Normal View History

2022-01-13 03:59:54 +00:00
using System.Collections;
using System.Collections.Generic;
using System.Linq;
2022-01-13 03:59:54 +00:00
using UnityEngine;
using RhythmHeavenMania.Editor.Track;
2022-01-13 03:59:54 +00:00
namespace RhythmHeavenMania.Editor
{
public class Selections : MonoBehaviour
{
public List<TimelineEventObj> eventsSelected = new List<TimelineEventObj>();
public static Selections instance { get; private set; }
private void Awake()
{
instance = this;
}
private void Update()
{
var buggedSelections = eventsSelected.FindAll(c => c == null);
if (buggedSelections.Count > 0)
{
for (int i = 0; i < buggedSelections.Count; i++)
Deselect(buggedSelections[i]);
}
}
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);
}
else
2022-01-13 03:59:54 +00:00
{
eventsSelected.Remove(eventToAdd);
}
2022-01-13 03:59:54 +00:00
}
public void DragSelect(TimelineEventObj eventToAdd)
{
if (!eventsSelected.Contains(eventToAdd))
{
eventsSelected.Add(eventToAdd);
}
}
public void DeselectAll()
{
eventsSelected.Clear();
}
public void Deselect(TimelineEventObj eventToDeselect)
{
if (eventsSelected.Contains(eventToDeselect))
{
eventsSelected.Remove(eventToDeselect);
}
}
}
}