Day 14. Tutorial: Create a scene flow - 10. Challenge Answer

如果你也有跟着教程做的话,第10节有个练习,可以来跟我交流一下答案,我也不知道我的写法是不是好的,但反正他work了。

 
 
 

10.Challenge: Set up the transition back to the Menu scene

Now users can get to the Main scene and exit the application from the starting menu, but at the moment they can’t get back to that menu from the Main scene.
We’ve created a Back to menu button in the Main scene, but you’ll need to get it working yourself.

Remember:

  • You can find the GameObject for the button in the Canvas GameObject.
  • The Canvas GameObject has the UI Main Scene (Script) component attached — this handles the UI in the Main scene.
  • You can review the process you followed in Configure the Start button if you get stuck.
  • Test your changes in Play mode to make sure they work properly.

 
 
 

 
 

我在Main场景的Canvas的C# Component(UIMainScene.cs) 加入了下面的BackMenu()

# UIMainScene.cs

private void Update()
{
    ...
}

public void BackMenu()
{
    SceneManager.LoadScene(0);
}

并把Canvas里被命名为Exit的方框图形的On Click()处,让他连接上Canvas的C#档案,并选择UIMainScene.BackMenu()作为On Click()时触发的Method。

 
 
这样就OK了~

参考:
https://learn.unity.com/tutorial/create-a-scene-flow?uv=2020.3&missionId=5f751af7edbc2a0022cdbbb6#60b73f73edbc2a5532d132d5


<<:  铁人赛 Day29 -- 使用 JQuery 制作简易的loading画面

>>:  D29 - 如何打包 Apps Script 的程序码?(二)包成 HTML 网页与或 API

HTTP & HTTPS

HTTP 和 HTTPS HTTP是甚麽? 定义 超文本传输协定**(英语:HyperText Tr...

Day19:今天来聊一下Denial-of-Service

拒绝服务(DoS)和分布式拒绝服务(DDoS)攻击已成为电脑网路的主要威胁。 这类攻击试图让机器或网...

[Day11] - Django REST Framework 介绍

在前几篇我们介绍了 Docker 以及 Docker Compose,让开发时的环境设定不会再因为作...

[Day. 26] Codeigniter 页面

昨天我们对更新资料库的资料进行了简单的操作, 我们对资料库已经可以新增、更新了 我们现在的情境是 i...