【发布时间】:2017-07-26 05:15:19
【问题描述】:
我是 Unity 的新手,我正在处理 Augmented reality project,我正在根据工作正常的标记显示 3D 对象。但我想要的是根据点击事件显示不同的对象
这是我到目前为止所做的场景:
- 我用带有标记的 3D 对象创建了 4 个不同的场景
- 制作了一个画布框架,我在上面放了 3 个按钮
-
在每个按钮单击中,我正在加载下一个场景,下面是我编写的代码。问题是它显示黑屏而不是加载新对象。我不想再次加载相机。谁能帮我这个?
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; // <<<<<< ADD THIS. public class Button_1 : MonoBehaviour { public void Button_Click() { Debug.Log("Hello, World!"); // Application.LoadLevel("Multi Target"); SceneManager.LoadScene("MultiTarget_1"); // <<<< Then Do this. } public void Button_Click2() { Debug.Log("Hello, World!"); // Application.LoadScene("Multi Target_1"); SceneManager.LoadScene("NameOfScene"); // <<<< Then Do this. } public void Button_Click3() { Debug.Log("Hello, World!"); Application.LoadLevel("Multi Target_2"); } public void Button_String(string msg) { Debug.Log("Hello, All!"); Application.LoadLevel("Multi Target_1"); } }
【问题讨论】:
-
有人为您添加了 SecenteManager.LoadScene 吗?
-
我已经尝试过了,但它不起作用你能解释一下我怎样才能做到这一点吗? @IgnacioAlorre
-
只是为了确定,您想要通过单击按钮更改的是场景而不是对象?当然每个场景都有自己的对象,但是你试着改变整个场景,不是吗?
-
我只想更改点击事件的对象而不是场景。在一个场景中,我想使用点击事件更改多个对象。
-
但似乎在您的脚本中,您尝试更改整个场景的每个按钮:SceneManager.LoadScene("NameOfScene");