我正在开发一个应用程序,使用Unity
,我创建了两个Scene
's。如果用户注视Scene 1
中的一个对象,它应该转到Scene 2
。我有下面的代码,但我得到错误。如何通过凝视一个对象在一个场景中从一个场景走向另一个场景?
源代码如下: -
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class time : MonoBehaviour {
public float gazeTime = 2f;
private float timer;
private bool gazedAt;
// Use this for initialization
void Start() {
}
void update(){
if (gazedAt)
{
timer += Time.deltaTime;
if (timer >= gazeTime)
{
Application.LoadLevel (scenetochangeto);
timer = 0f;
}
}
}
public void ss(string scenetochangeto)
{
gameObject.SetActive (true);
}
public void pointerenter()
{
//Debug.Log("pointer enter");
gazedAt = true;
}
public void pointerexit()
{
//Debug.Log("pointer exit");
gazedAt = false;
}
public void pointerdown()
{
Debug.Log("pointer down");
}
}
是啊!非常感谢你 !!我尝试使用同一个脚本来处理按钮,但它不起作用。如何解决它。 –
是啊!非常感谢你 !!我尝试使用同一个脚本来处理按钮,但它不起作用。如何解决它。 –
在'使用UnityEngine.SceneManagement'后添加'使用UnityEngine.EventSystems'' –