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

博客介绍了Unity3D中开始界面和结束界面的创建方法。开始界面需创建新场景、添加button,编写C#脚本LoadingGame.cs,建空对象并拖入脚本,添加到button,最后在Building Settings中加入场景。结束界面同理,使用endGame.cs脚本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

开始界面

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");
    }
}

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();
    }
}

调用

Application.LoadLevel("endGame");
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值