编程语言;通过编写的程序控制
C#script大路通用
编程语言;通过编写的程序控制
C#script大路通用
浮点类型号;
//注释不能破坏原有的结构
//通过注释来解释这个代码是干什么的,方便别人去理解和阅读代码
/*这是多行注释的开头
*/这是多行注释的结尾
两个符号的中间都是注释的范畴
ctrl+k 后,再按 crtl+c
Debug.Log("字符串");
Debug.Log(int);//提示信息
Debug.LogWarning("string");//提示警告
Debug.LogError("string");//
使用循环遍历数组元素,
for(类型加i+i<可以确定数组长度+i++)
for(类型加i+i<数组名+length+i++)
第二种在不确定数组长度情况下,是比较灵活的
for循环语句:
for(类型加上一个i+循环次数终止条件+是否增值i++)
代码输出方式:
1.针对组件输出:print('alksjdlkjasd');
2.什么都能输出:Debug.Log('sdfsdfsfd');
3.警告输出:Debug.LogWarning('sdfsdfsfd');
4错误输出:Debug.LogError(''46546);
//单行注释
/* */多行注释
一般多行注释结构如下:
/*lasdajh
*asdkaskd
*
*
*/
//可以有多个类,但是用的时候需要在头部 using MyGame;
public class Player :MonoBehaviour{
void Start(){
//初始方法
GameData data;
}
void Update(){
只调用一次
}
}
namespace MyGame{
classGameData{
}
}
//获取鼠标的左右按钮
input 类 GetAxis方法 Horizontal参数
private void Update(){
Input.GetAxis("Horizontal");
}
int,声明变量,变量可在运行期间变化,单纯的数字不行
1.Debug.Log在什么时候都能用(输出正常)
2.Debug.LogWarning在什么时候都能用(输出警告)
3.Debug.LogError在什么时候都能用(输出错误)
4.print需要在有MonoBehaviour的情况下才能用(输出正常)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour {
// Use this for intitialization
void start () {
//print(1);// ( ) () ; ;
//print (3223);
//Debug.Log(1);
//Debug.Log("3223");
//Debug.logWarning("23423");
//Debug.logError("23423");
//变量
//赋值 = 把右边的赋值付给左边的变量
int hp = 100; // int hp; 声明变量
hp = 90;
print(100);
print(hp);//初始化
int hp;
//
}
//Update is called once per frame
void Update () {
//print(2);
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour {
// Use this for intitialization
void start () {
//print(1);// ( ) () ; ;
//print (3223);
//Debug.Log(1);
//Debug.Log("3223");
//Debug.logWarning("23423");
//Debug.logError("23423");
//变量
//赋值 = 把右边的赋值付给左边的变量
int hp = 100; // int hp; 声明变量
hp = 90;
print(100);
print(hp);//初始化
int hp;
//
}
//Update is called once per frame
void Update () {
//print(2);
int是整数类型,只允许附整数的值。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour {
// Use this for intitialization
void start () {
//print(1);// ( ) () ; ;
//print (3223);
//Debug.Log(1);
//Debug.Log("3223");
//Debug.logWarning("23423");
//Debug.logError("23423");
//变量
//赋值 = 把右边的赋值付给左边的变量
int hp = 100; // int hp; 声明变量
hp = 90;
print(100);
print(hp);
}
//Update is called once per frame
void Update () {
//print(2);
//变量
//赋值 = 把右边的赋值付给左边的变量
int hp = 100; // int hp;
print(hp);
注意:变量不能以数字开头!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour {
// Use this for intitialization
void start () {
print(1);// ( ) () ; ;
print (3223);
Debug.Log(1);
Debug.Log("3223");
Debug.logWarning("23423");
Debug.logError("");
}
// Update is called once per frame
void Update () {
}
}
// sf sfsd sdfsdf 第三方斯蒂芬斯蒂芬斯蒂芬
/*
sldkfjlsdkjfa lkjd
*/
/*
*
*
*
*
*/
注意:Error是错误,warning是警告
通过print是正常的输出,通过Debug是可以把日志输出分为三列
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour {
// Use this for intitialization
void start () {
}
// Update is called once per frame
void Update () {
}
}
// sf sfsd sdfsdf 第三方斯蒂芬斯蒂芬斯蒂芬
/*
sldkfjlsdkjfa lkjd
*/
/*
*
*
*
*
*/