简体   繁体   English

在其他场景 Unity 中显示按钮

[英]Show Button in Other Scene Unity

I want to ask something, can we load (show) button in difference scene (scene B) from button I (clicked) in my main scene (scene A), and scene change to scene B,我想问一些问题,我们可以从我的主场景(场景 A)中的按钮 I(单击)加载(显示)不同场景(场景 B)中的按钮,然后场景切换到场景 B,

Thanks before,之前谢谢

If you are asking how you can show a button in one scene (A) then click a button in (A) then go to a new scene (B), you can do this using SceneManager .如果您询问如何在一个场景 (A) 中显示一个按钮,然后单击 (A) 中的一个按钮,然后单击 go 到一个新场景 (B),您可以使用SceneManager执行此操作。

using UnityEngine.SceneManagement; 

// assign your button's onclick to be this function
public void LoadNewScene()
{
     SceneManagement.LoadScene("YOUR_SCENE_NAME_HERE");
}

Make sure to add the scene you want to load to your build settings.确保将要加载的场景添加到构建设置中。 Without it being added, it will not be able to load it.如果不添加它,它将无法加载它。 Here is a more detailed page about LoadScene. 是有关 LoadScene 的更详细的页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM