常量值:无法变化的值及固定值
1、整型
int类型
2、浮点类型
float类型
double类型
常量值:无法变化的值及固定值
1、整型
int类型
2、浮点类型
float类型
double类型
声明,赋值
DebugLog("1234");
DebugWarning("1234");
DebugError("1234");
枚举类型用来定义和角色 职业类型
选中行
Ctrl K Ctrl C
/* 多行注释开头
*/
for(int i=1;i<=10;i++自增运算符){
循环体print("创建一个敌人 "+i)可以看到创建的数值
}
for(int i = 0; i < 10; i++){
print("创建敌人");
}
int[] hps = new int [10];
这个数组的长度为10,默认初始化值为0
hps[0]=20;
int[] hps;数组不存在int[] hps = null;
int[] hps2 = { };
int[] hps = new int[5] {34,2,3,};
创建了数组长度
int[] hps = {100,20,80,90};
通过索引来访问数据
从0开始访问
数组名[索引]print(hps[1]);
if(hp<=0){
}
else
int整数
int变量类型 hp变量的名字 = 100变量的数值;
print只能在MonoBehaviour下输出
Debug.Log可以再任意类下输出
Debug.LogWarning输出警告
Debug.Log
using UnityEngine; namespace命名空间
print(1);输出1
void start 执行一次 做初始化
void Update每一帧进行调用
ctrl+k再ctrl+C_把东西注释
int hp=100
hp不能以数字开头,hp一般代表血量
在Start方法里定义的变量只能在start里使用(就是
Debug.Log()在所有都可用
print()只在组件(如继承了MonoBehaviour)才可用
Debug.LogWarning()用于输出警告(前标黄)
Debug. LogError()用于输出错误(前标红色)
int[] hps={100,23,65,87,90];
print(hps[1]);
位置:window consale
有monobhaviour就可以输出
第一个方式:print输出
第二个方式:debug.log();(只在monobhaviour中输出)(输出比print多)
第三个方式:debug.logwarning(输出经过)(有可能错误的地方)
第四个方式:debug.logerror(直接显示错误)
提示:可以在consale中选择不显示的输出
作用:帮助调试游戏
transform 本身的数组下标 child【i】=transform