0
按照主题,在尝试运行项目时遇到此错误消息。即使我已经导入UnityEngine命名空间,仍然会出现错误消息。名称'GUIUtilities'在当前上下文中不存在
Assets/Scripts/QRCodeReaderGUI.cs(14,22): error CS0103: The name 'GUIUtilities' does not exist in the current context
我的代码
using UnityEngine;
using System.Collections;
public class QRCodeReaderGUI : MonoBehaviour {
public GUIStyle buttonTextStyle;
public GUIStyle textStyle;
float SizeFactor;
private string qrCode;
void Start()
{
SizeFactor = GUIUtilities.SizeFactor;
}
void Update()
{
SizeFactor = GUIUtilities.SizeFactor;
}
void OnGUI()
{
if (GUIUtilities.ButtonWithText(new Rect(
Screen.width - 200 * SizeFactor,
0,
200 * SizeFactor,
100 * SizeFactor), "Back", null, buttonTextStyle) || Input.GetKeyDown(KeyCode.Escape))
{
PlayerPrefs.SetInt("backFromARScene", 1);
Application.LoadLevel("MainMenu");
}
GUIUtilities.Text(new Rect(0, 0, Screen.width, 300 * SizeFactor), "Last QR code read: \n" + qrCode, textStyle);
}
public void setCode(string qrCode)
{
this.qrCode = qrCode;
}
}
请指教。
参考:http://docs.unity3d.com/ScriptReference/GUIUtility.html