-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventOnMouseScroll.cs
More file actions
94 lines (82 loc) · 2.96 KB
/
Copy pathEventOnMouseScroll.cs
File metadata and controls
94 lines (82 loc) · 2.96 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using GameCreator.Runtime.Common;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.InputSystem.Utilities;
namespace GameCreator.Runtime.VisualScripting
{
[Version(1, 0, 1)]
[Title("On Mouse Wheel Scrolling")]
[Category("Input/On Mouse Wheel Scrolling")]
[Description("Detects when mouse wheel is scrolling, has stopped, or scrolled in specific directions")]
[Image(typeof(IconScroll), ColorTheme.Type.Yellow)]
[Keywords("Keyboard", "Mouse", "Wheel", "Gamepad", "Controller", "Joystick")]
[Serializable]
public class EventOnMouseScroll : Event
{
// MEMBERS: -------------------------------------------------------------------------------
float mouseWheel;
Vector2 m_Vec;
private enum MouseScrollAction
{
m_ScrollingStart,
m_ScrollingStop,
m_ScrollUp,
m_ScrollDown
};
[SerializeField] private MouseScrollAction mouseAction;
// NON-MEMBERS: -------------------------------------------------------------------------------
private bool stop = true;
// RUN METHOD: ----------------------------------------------------------------------------
protected override void OnStart(Trigger trigger)
{
base.OnStart(trigger);
}
protected override void OnDestroy(Trigger trigger)
{
base.OnDestroy(this.m_Trigger);
}
protected override void OnUpdate(Trigger trigger)
{
m_Vec = Mouse.current.scroll.ReadValue();
mouseWheel = m_Vec.y;
switch (mouseAction)
{
case MouseScrollAction.m_ScrollUp:
if (mouseWheel > 0f)
{
_ = this.m_Trigger.Execute(this.Self);
}
break;
case MouseScrollAction.m_ScrollDown:
if (mouseWheel < 0f)
{
_ = this.m_Trigger.Execute(this.Self);
}
break;
case MouseScrollAction.m_ScrollingStart:
if (mouseWheel != 0f)
{
_ = this.m_Trigger.Execute(this.Self);
}
break;
case MouseScrollAction.m_ScrollingStop:
if (stop == true)
if (mouseWheel == 0f)
{
if (stop == true)
{
_ = this.m_Trigger.Execute(this.Self);
stop = false;
}
}
if (mouseWheel != 0f)
{
stop = true;
}
break;
}
}
}
}