来使用浮子而不是双打
我在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