Unity中的随机数
Unity中的Random是Unity中特有的,与C#的不一样
cs
int randoNum = Random.Range(0, 100);
float randoNumF = Random.Range(1.1f, 99.9f);
使用随机数 int 重载 规则是左包含,右不包含
使用浮点数重载,规则是左右都包含
cs
Random rd = new Random();
int i = rd.Next();
c#中的Random随机数是左包含右不包含
Unity的自带委托
c#中的委托
cs
System.Action ac = () =>
{
print("123");
};
System.Action<int, float> ac2 = (i, f) =>
{
};
System.Func<int> fun1 = () =>
{
return 1;
};
System.Func<int, string> fun2 = (i) =>
{
return "123";
};
Unity中的委托
要引用using UnityEngine.Events;
cs
UnityAction uac = () =>
{
};
UnityAction<string> uac2 = (str) =>
{
};