Game Development Reference
In-Depth Information
for (var callback in _callbacks) {
callback();
}
}
}
If we check out this script, we will see that this script uses
List<T>
, which is available
in the C# generic library, so we need to use
import Sys-
tem.Collections.Generic;
.
Note
List<T>
is basically similar to JavaScript's the
Array
or
ArrayList
type, but we
need to specify the
<T>
type. This also performs significantly faster than JavaScript's
Array
and
ArrayList
. A good link to understand which type of array to use in Unity
is as follows:
We will see that we have
List
to store the
Function
type. Then, we have
Add
,
Re-
move
,
Clear
, and
Invoke
functions. The
Invoke()
function is basically to call all
the functions in
List
. This is similar to the
delegate
and
event
functions in C#.