输入和输出:
print(1);
print("23456");//只能在继承MonoBehaviour环境中使用
Debug.Log(1);//在任意环境中可以输出
Debug.LogWarning("")//警告
Debug.LogError(“”);//在日志里面显示 错误
数据类型:
bool 类型常用于判断是否正确。//bool res= 100>78;会返回ture
float 浮点型 float hp2=3,4f;//注意f
char 字符型;
string name ="绝地武士";字符串型
字符串相加:
string str1="aaa";
string str2="bbb";
string strRes=str1+str2;
print(strRes);
循环语句:
if(){}else{}语句;
for()循环,
// 遍历数组
for(int i=0;i<hps.Length;i++)
{
print(hps[1]);
}
switch() case;语句
switch(heroType)
{
case 0:print();break;
case 1:print();break;
defalt;break;
}
while()
数组:
声明数组 法1:类型 [] 数组名={数组值} // int [] hps={10,20,10};
法二:int[] hps=new int [20];//数组长度为20;使用这种方式会使用默认值0初始化。</