application.loadlevel不起作用



我在IF语句

内使用Application.LoadLevel遇到困难

这是代码:

using UnityEngine;
using System.Collections;
public class Ritch: MonoBehaviour {

public bool dragging = false;
void Update () {
    if (PreRitch.Deathritch == true)
    {
        transform.position = new Vector3(8f,6.89f,9f);
    }
    if (transform.position.x > 11.5 && dragging == false)
    {
        Application.LoadLevel(0);
    }
    else if (transform.position.x < 4.5 && dragging == false)
    {
        Application.LoadLevel(0);
    }

}
void OnMouseDown()
{
    dragging = true;
}
void OnMouseUp()
{
    dragging = false;
}
}

该程序没有加载所需的级别,如果我将打印语句放入其中一个If语句中,则没有打印任何内容。

尝试将代码更改为:

using UnityEngine;
using System.Collections;
public class Ritch: MonoBehaviour {

public bool dragging = false;
void Update () {
    if (PreRitch.Deathritch == true)
    {
        transform.position = new Vector3(8f,6.89f,9f);
    }
    //if (transform.position.x > 11.5 && dragging == false)
    if (transform.position.x > 11.5f && dragging == false)
    {
        //Application.LoadLevel(0);
        UnityEngine.SceneManagement.SceneManager.LoadScene(0);
    }
    //else if (transform.position.x < 4.5 && dragging == false)
    else if (transform.position.x < 4.5f && dragging == false)
    {
        //Application.LoadLevel(0);
        UnityEngine.SceneManagement.SceneManager.LoadScene(0);
    }

}
void OnMouseDown()
{
    dragging = true;
}
void OnMouseUp()
{
    dragging = false;
}
}

您可以通过添加f或f char

来使用浮子而不是双打

相关内容

  • 没有找到相关文章

最新更新