声明:给类型,给名字
初始化:给初值
赋值类型一致
声明:给类型,给名字
初始化:给初值
赋值类型一致
变量:存储数据
ctrl+k ctrl+c 快捷注释
Debug.Log()
Debug.LogWarning()
Debug.LogError()
日志的分类
单行注释://
多行注释:/* */
脚本名和类名保持一致
Start方法,执行一次,常初始化
Update方法,每帧执行一次
1.float 必须在赋值后面加f
2.赋值时前后数据类型必须一致
定义数值变量到面板中q
public int hp
Debug.Log() 在任意场景输出
Debug.LogWarning() 输出警告
Debug.LogError() 输出错误
脚本文件名与类名一致
F12修改脚本文件名,要手动修改类名
ctrl+s 保存场景
修改代码后要等待unity识别新代码
print 输出
int[] hps={100.90,80,50};
string str1="name is";
string str2="ll";
string strRes=ste1+str2;
print(strRes);
int hp=100;
bool res=hp>0;
print(res);
Debug.logWarning
Debug.logError
roletype 角色类型
i<hps.Length 访问数组长度 在不知道数组长度的情况下
for循环
for (int i=1;i<=100;i++)
{(print"敌人"+i);}
输出100次
数组 类型名【】数组名={数组值}
int【】hps ={100,20,50,42,30} //数组长度为5
0 1 2 3 4
print(hps[1])=20;
通过.Length可以访问到数组长度
bool 类型 输出 true