zl程序教程

您现在的位置是:首页 >  其它

当前栏目

Unity3D_最简单的开始界面_结束界面

简单 界面 开始 Unity3D 结束
2023-09-27 14:20:56 时间

开始界面
1、创建一个新的场景
添加button

2、C#脚本
LoadingGame.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LoadingGame : MonoBehaviour
{
public void LoadGame()
{
Application.LoadLevel("mianScene");
}
}
1
2
3
4
5
6
7
8
9
10
11
3、建一个空对象
将LoadingGame.cs拖入


4、添加到button中

5、在Building Settings中加入两个场景

 

然后就可以尝试运行啦~

结束界面
同理——结束界面
endGame.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class endGame : MonoBehaviour
{
public void EndGame()
{
UnityEditor.EditorApplication.isPlaying = false;
Application.Quit();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
调用

Application.LoadLevel("endGame");
---------------------