Make sure you can only select when the selection state is set

This commit is contained in:
Braedon 2022-01-30 14:04:15 -05:00
parent bc8f7419be
commit a910701b1c
4 changed files with 139 additions and 146 deletions

View file

@ -1,145 +1,130 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: e60958662eed5413d86143a0a69b731e guid: e60958662eed5413d86143a0a69b731e
timeCreated: 1491979494
licenseType: Pro
PluginImporter: PluginImporter:
externalObjects: {}
serializedVersion: 2 serializedVersion: 2
iconMap: {} iconMap: {}
executionOrder: {} executionOrder: {}
defineConstraints: []
isPreloaded: 0 isPreloaded: 0
isOverridable: 0 isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData: platformData:
data: - first:
first: : Any
'': Any second:
second: enabled: 0
enabled: 0 settings:
settings: Exclude Android: 1
Exclude Android: 1 Exclude Editor: 0
Exclude Editor: 0 Exclude Linux: 1
Exclude Linux: 1 Exclude Linux64: 1
Exclude Linux64: 1 Exclude LinuxUniversal: 1
Exclude LinuxUniversal: 1 Exclude OSXIntel: 1
Exclude OSXIntel: 1 Exclude OSXIntel64: 1
Exclude OSXIntel64: 1 Exclude OSXUniversal: 1
Exclude OSXUniversal: 1 Exclude WebGL: 1
Exclude WebGL: 1 Exclude Win: 0
Exclude Win: 0 Exclude Win64: 0
Exclude Win64: 0 Exclude iOS: 1
Exclude iOS: 1 - first:
data: : Editor
first: second:
'': Editor enabled: 0
second: settings:
enabled: 0 CPU: AnyCPU
settings: OS: AnyOS
CPU: AnyCPU - first:
OS: AnyOS Android: Android
data: second:
first: enabled: 0
Android: Android settings:
second: CPU: ARMv7
enabled: 0 - first:
settings: Any:
CPU: ARMv7 second:
data: enabled: 0
first: settings: {}
Any: - first:
second: Editor: Editor
enabled: 0 second:
settings: {} enabled: 1
data: settings:
first: DefaultValueInitialized: true
Editor: Editor - first:
second: Facebook: Win
enabled: 1 second:
settings: enabled: 0
DefaultValueInitialized: true settings:
data: CPU: AnyCPU
first: - first:
Facebook: Win Facebook: Win64
second: second:
enabled: 0 enabled: 0
settings: settings:
CPU: AnyCPU CPU: AnyCPU
data: - first:
first: Standalone: Linux
Facebook: Win64 second:
second: enabled: 0
enabled: 0 settings:
settings: CPU: None
CPU: AnyCPU - first:
data: Standalone: Linux64
first: second:
Standalone: Linux enabled: 0
second: settings:
enabled: 0 CPU: None
settings: - first:
CPU: None Standalone: LinuxUniversal
data: second:
first: enabled: 0
Standalone: Linux64 settings:
second: CPU: None
enabled: 0 - first:
settings: Standalone: OSXIntel
CPU: None second:
data: enabled: 0
first: settings:
Standalone: LinuxUniversal CPU: None
second: - first:
enabled: 0 Standalone: OSXIntel64
settings: second:
CPU: None enabled: 0
data: settings:
first: CPU: None
Standalone: OSXIntel - first:
second: Standalone: OSXUniversal
enabled: 0 second:
settings: enabled: 0
CPU: None settings:
data: CPU: None
first: - first:
Standalone: OSXIntel64 Standalone: Win
second: second:
enabled: 0 enabled: 1
settings: settings:
CPU: None CPU: AnyCPU
data: - first:
first: Standalone: Win64
Standalone: OSXUniversal second:
second: enabled: 1
enabled: 0 settings:
settings: CPU: AnyCPU
CPU: None - first:
data: Windows Store Apps: WindowsStoreApps
first: second:
Standalone: Win enabled: 0
second: settings:
enabled: 1 CPU: AnyCPU
settings: - first:
CPU: AnyCPU iPhone: iOS
data: second:
first: enabled: 0
Standalone: Win64 settings:
second: CompileFlags:
enabled: 1 FrameworkDependencies:
settings:
CPU: AnyCPU
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
iPhone: iOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View file

@ -20,6 +20,8 @@ namespace RhythmHeavenMania.Editor
public bool selecting = false; public bool selecting = false;
private bool clickedInTimeline = false;
public static BoxSelection instance { get; private set; } public static BoxSelection instance { get; private set; }
private void Awake() private void Awake()
@ -46,7 +48,7 @@ namespace RhythmHeavenMania.Editor
return; return;
} }
if (Conductor.instance.NotStopped()) if (Conductor.instance.NotStopped() || !Timeline.instance.timelineState.selected)
{ {
startPosition = Vector2.zero; startPosition = Vector2.zero;
endPosition = Vector2.zero; endPosition = Vector2.zero;
@ -57,12 +59,14 @@ namespace RhythmHeavenMania.Editor
// click // click
if (Input.GetMouseButtonDown(0)) if (Input.GetMouseButtonDown(0))
{ {
clickedInTimeline = Timeline.instance.CheckIfMouseInTimeline();
startPosition = MousePosition(); startPosition = MousePosition();
selectionBox = new Rect(); selectionBox = new Rect();
} }
// dragging // dragging
if (Input.GetMouseButton(0)) if (Input.GetMouseButton(0) && clickedInTimeline)
{ {
endPosition = MousePosition(); endPosition = MousePosition();
DrawVisual(); DrawVisual();

View file

@ -134,6 +134,7 @@ namespace RhythmHeavenMania.Editor
} }
} }
if (Timeline.instance.timelineState.selected == true)
if (Input.GetMouseButtonUp(0) && Timeline.instance.CheckIfMouseInTimeline()) if (Input.GetMouseButtonUp(0) && Timeline.instance.CheckIfMouseInTimeline())
{ {
List<TimelineEventObj> selectedEvents = Timeline.instance.eventObjs.FindAll(c => c.selected == true && c.eligibleToMove == true); List<TimelineEventObj> selectedEvents = Timeline.instance.eventObjs.FindAll(c => c.selected == true && c.eligibleToMove == true);

View file

@ -66,7 +66,7 @@ namespace RhythmHeavenMania.Editor.Track
selected = Selections.instance.eventsSelected.Contains(this); selected = Selections.instance.eventsSelected.Contains(this);
entity = GameManager.instance.Beatmap.entities.Find(a => a.eventObj == this); entity = GameManager.instance.Beatmap.entities.Find(a => a.eventObj == this);
mouseHovering = RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main); mouseHovering = RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition, Camera.main) && Timeline.instance.timelineState.selected;
#region Optimizations #region Optimizations
@ -117,7 +117,7 @@ namespace RhythmHeavenMania.Editor.Track
if (!resizing) if (!resizing)
{ {
if (Input.GetMouseButtonUp(0) && Timeline.instance.CheckIfMouseInTimeline()) if (Input.GetMouseButtonUp(0) && Timeline.instance.CheckIfMouseInTimeline() && Timeline.instance.timelineState.selected)
{ {
if (Timeline.instance.eventObjs.FindAll(c => c.mouseHovering).Count == 0 && Timeline.instance.eventObjs.FindAll(c => c.moving).Count == 0 && !BoxSelection.instance.selecting && Timeline.instance.eventObjs.FindAll(c => c.resizing).Count == 0) if (Timeline.instance.eventObjs.FindAll(c => c.mouseHovering).Count == 0 && Timeline.instance.eventObjs.FindAll(c => c.moving).Count == 0 && !BoxSelection.instance.selecting && Timeline.instance.eventObjs.FindAll(c => c.resizing).Count == 0)
{ {
@ -198,22 +198,25 @@ namespace RhythmHeavenMania.Editor.Track
public void OnClick() public void OnClick()
{ {
if (Input.GetKey(KeyCode.LeftShift)) if (Input.GetMouseButton(0) && Timeline.instance.timelineState.selected)
{ {
Selections.instance.ShiftClickSelect(this); if (Input.GetKey(KeyCode.LeftShift))
}
else
{
if (!selected)
{ {
Selections.instance.ClickSelect(this); Selections.instance.ShiftClickSelect(this);
}
else
{
if (!selected)
{
Selections.instance.ClickSelect(this);
}
} }
} }
} }
public void OnDown() public void OnDown()
{ {
if (selected) if (selected && Timeline.instance.timelineState.selected)
{ {
lastPos_ = transform.localPosition; lastPos_ = transform.localPosition;
@ -235,7 +238,7 @@ namespace RhythmHeavenMania.Editor.Track
// lastPos_ = this.lastPos_; // lastPos_ = this.lastPos_;
// previousPos = this.transform.localPosition; // previousPos = this.transform.localPosition;
if (selected) if (selected && Timeline.instance.timelineState.selected)
{ {
if (eligibleToMove) if (eligibleToMove)
{ {