-
Notifications
You must be signed in to change notification settings - Fork 5
/
Main.cs
54 lines (43 loc) · 1.18 KB
/
Main.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using UnityEngine;
namespace Section.Delegates_Events.Delgates
{
public class Main : MonoBehaviour
{
public delegate void ChangeColor(Color newColor);
public ChangeColor onColorChange;
public delegate void OnComplete();
public OnComplete onComplete;
// Start is called before the first frame update
void Start()
{
onColorChange = UpdateColor;
onColorChange(Color.green);
// signitures must match
// onColorChange = Task;
onComplete += Task;
onComplete += Task2;
onComplete += Task3;
onComplete -= Task3;
if (onComplete != null)
{
onComplete();
}
}
public void UpdateColor(Color newColor)
{
Debug.Log("Changing color to: " + newColor.ToString());
}
public void Task()
{
Debug.Log("Task 1 Finished");
}
public void Task2()
{
Debug.Log("Task 2 Finished");
}
public void Task3()
{
Debug.Log("Task 3 Finished");
}
}
}