输出方式:
print() 只能在组件中使用
debug()
输出方式:
正常输出:Debug.Log()
警告输出:Debug.LogWarning()
错误输出:Debug.LogError()
输出方式:
print() 只能在组件中使用
debug()
输出方式:
正常输出:Debug.Log()
警告输出:Debug.LogWarning()
错误输出:Debug.LogError()
;结束
1秒50帧
print?
打开scripts
解释namespace :命名空间
类名nbs
enum RoleType{
Mag
}
两个数据类型做运算,结果取较大的数据类型
Transform[] children = transform.GetComponentsInChildren<Transform>();
1.for循环
for(int i=0;i<children.Length;i++)
{
GameObject.Destroy(children[i].gameObject);
}
2.while循环
int i = 0;
while (i < children.Length)
{
if (children[i] != transform)
{
GameObject.Destroy(children[i].gameObject);
}
i++;
}
3.do while
int i = 0;
do
{
if (children[i] != transform)
{
GameObject.Destroy(children[i].gameObject)
}
} while (i < children.Length);
1.代码和属性面板值不同时,以属性面板值为准
2.代码中public在属性面板中显示,private不在属性面板中显示
3.默认是private
1.类声明的变量 叫做对象
2.new enemy是构造对象
数组没有初始化变量按默认来 0
1.数组
int[] hps={100,90,80,20,10}
2.通过索引来访问数据hps[1]
1.Debug.Log可以在任何类和方法中使用
print只能在MonoBehaviour中使用
Debug.LogWarning输出警告
1.脚本名字与类名要保持一致
2.f2修改文件名
3.场景的保存 代码的保存 代码先保存
1秒大约50帧
1只有一次,2输出很多次
现在看这个还有用吗??
控制台输出 Debuy.Log( );
控制台警告输出 Debuy.logWarning( );
控制台错误输出 Debuy.LogError( );
数组
int hp=100;
int[]hps={100,50,25,17,9,5}; 数组长度为5
通过索引来访问数据0 数组名[索引]
print(hps[1]);
是否死亡:
int hp=0
if(hp<=0 )
{
print(''你死了'')
} //判断你的血量是否等于或 小 于0,如果是就说你死了
比较运算符
< > >= <= !=
bool res=7>5; 判断7是否大于5
int hp=100; 设血量为100
bool res=hp>0; 判断血量是否大于0
print(res); 输出是否
hp=hp+10 血量加10
hp++; =hp=hp+1
hp--; =hp=hp_1
int a=10 设a等于10
int b=20 设b等于20
int res=a+b 设res等于a+b
print(res); 输出答安
res=变量
10=常量
两个整数相除,小数部分会自动舍去
float res4=3+3.2f 可以保留小数
string str1=''123'';设str1名字叫123
string str2=''321'';设str2叫321
string rees=str1+str2;设rees叫str1+str2的名字
1,bool(true或false) 判断
bool isdie=true
2,char c='a';
string name=dhin
数据类型
整数类型常用
int(-2147483648~2147483648)最常用
short (-32768~32767)
sbyte(-128~127)
浮点(小数)类型
float(28位)常用
float hp2=3.4 错
float hp2=3.4f 对