preLesson
public class Lesson1 : MonoBehaviour
{
//切换场景
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
//切换到L1T2
//需要把场景添加到场景列表中
SceneManager.LoadScene("L1T2");
}
//退出游戏
if(Input.GetKeyDown(KeyCode.Escape))
{
//在编辑模式下没有用
Application.Quit();
}
}
}
public class Lesson2 : MonoBehaviour
{
public Texture2D tex;
// Start is called before the first frame update
void Start()
{
//隐藏鼠标
Cursor.visible = false;
//锁定鼠标
//None 不锁定
//Locked 把鼠标锁定在屏幕中心,并隐藏鼠标
//Confined 限制在窗口范围内
Cursor.lockState = CursorLockMode.None;
//设置鼠标图片
//参数一 光标图片
//参数一 偏移位置,相对图片左上角
//参数三 平台支持的光标模式(硬件或软件)
Cursor.SetCursor(tex, Vector2.zero, CursorMode.Auto);
}
}
public class Lesson3 : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
//随机数
//Unity中的随机数
//Unity当中的Random类不是C#中的Random类
//int左包含右不包含
int randnum = Random.Range(0,100);//0~99
//float左右都包含
float randfloat = Random.Range(1.1f, 99.9f);
//C#中的随机数
System.Random rand = new System.Random();
rand.Next(0, 100);
//C#自带的委托
System.Action ac = () =>
{
print("123");
};
//Unity自带委托
UnityAction uac = () => { };
}
}
Unity支持的模型格式 fbx dae 3ds dxf obj , 推荐fbx

浙公网安备 33010602011771号