2015-05-26 22 views
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

回答

1

嘗試把: 使用UnityEngine.GUIUtility;

如果不能正常工作,請嘗試查看該組件在Unity 5.0中是否工作正常。新版本改變了很多GUI的工作方式。

或者,您可以使用UI.Text並將: 使用UnityEngine.UI;

相關問題