-
Notifications
You must be signed in to change notification settings - Fork 0
/
Clicker.cs
35 lines (30 loc) · 1.01 KB
/
Clicker.cs
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class Clicker : MonoBehaviour
{
private bool toggleOn = false;
private bool controlsEnabled = false;
private Action disableControlsListener;
private Action enableControlsListener;
void Start()
{
enableControlsListener = new Action(() => { controlsEnabled = true; });
disableControlsListener = new Action(() => { controlsEnabled = false; });
EventManager.StartListening("EnableControls", enableControlsListener);
EventManager.StartListening("DisableControls", disableControlsListener);
}
void Update ()
{
if ((Input.GetMouseButtonDown(0) || Input.GetMouseButtonUp(0)) && !toggleOn && controlsEnabled)
{
EventManager.TriggerEvent("ToggleDots");
}
if (Input.GetMouseButtonDown(1) && controlsEnabled)
{
EventManager.TriggerEvent("ToggleDots");
toggleOn = !toggleOn;
}
}
}