I want to use Times function in a Unity, by following this site I use this script.
public static class IntExtensions
{
public static void Times(this int i, Action<int> func)
{
for(int j = 0; j < i; j++)
{
func(j);
}
}
}
But it causes error:
Assets/Resources/Scripts/Board.cs(27,40): error CS0246: The type or namespace name
Action 1could not be found. Are you missing a using directive or an assembly reference?
It looks like there is no Action in Unity C#.
Is there way to use the function in Unity? And where should I put the file if I want to use throughout my Unity project?
The Action<T> delegate type is defined in the System namespace - make sure you have using System; as a directive at the top of your CS file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With