【发布时间】:2018-02-19 20:59:50
【问题描述】:
我在 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 语句中放置了一条打印语句,则不会打印任何内容。
【问题讨论】:
-
可能你的
if语句表达式是假的? -
我放了一个打印声明,结果是真的
-
你说
if I put a print statement inside of one of the if statements nothing is printed. -
我把 print 语句放在 void update 而不是 if 语句中
-
您必须确保您的布尔表达式可以变为真,并且您已将关卡添加到构建设置中
标签: c# unity3d game-development