2016-08-21 11 views
-2

私はゲームメニューを作ろうとしています。このためには、私はGUIlayoutとその方法が必要です。しかし、Unityのように見えますが、このエラーを表示し、GUIlayoutオブジェクトを見つけることができません。Unity3D v5.4 - GUILayoutは存在しません

Assets/scripts/GameManager.cs(38,25): error CS0103: The name `GUIlayout' does not exist in the current context

はマイコード:

using UnityEngine; 
using UnityEditor; 
using System.Collections; 

public class GameManager : MonoBehaviour { 

public bool isMenuActive{get;set;} 

void Awake() { 
    isMenuActive = true; 
} 

void OnGUI(){ 
    const int Width = 300; 
    const int Height = 200; 
    if (isMenuActive){ 
     Rect windowRect = new Rect((Screen.width - Width)/2 ,(Screen.height - Height)/2, Width , Height); 
     GUIlayout.window(0,windowRect,MainMenu,"Main menu"); 
    } 
} 

private void MainMenu(){ 
    // Debug.Log("menu is displayed"); 
} 

} 

任意のアイデア?

+0

ASP.NETの[エラーCS0103]の重複可能性があります(http://stackoverflow.com/questions/5119207/error-cs0103-in-asp-net) –

+1

「GUIlayout」ではなく「GUILayout」である必要があります。 。 (大文字と小文字を区別)Unity 5.4ではOnGUIを使用しないでください。間もなく、そのサポートは中止されます。 UnityUIを使用してください。 –

答えて

1

問題は、コードの行から次のとおりです。

GUILayout.Window(0, windowRect, MainMenu, "Main menu"); 

.ITのGUILayoutないGUIlayout。 'L'は大文字になります。使用GUILayout

選択図静的関数はWindowないwindowあります。問題1と同じ資本化問題。

Window関数の3番目のパラメータには、それに渡すintパラメータを持つ関数が必要です。 MainMenu関数をintでパラメータ化する必要があります。

public class GameManager : MonoBehaviour 
{ 

    public bool isMenuActive { get; set; } 

    void Awake() 
    { 
     isMenuActive = true; 
    } 

    void OnGUI() 
    { 
     const int Width = 300; 
     const int Height = 200; 
     if (isMenuActive) 
     { 
      Rect windowRect = new Rect((Screen.width - Width)/2, (Screen.height - Height)/2, Width, Height); 
      GUILayout.Window(0, windowRect, MainMenu, "Main menu"); 
     } 
    } 

    private void MainMenu(int windowID) 
    { 
     // Debug.Log("menu is displayed"); 
    } 
} 

最後に、thisを使用しないでください。 newユニティUIを使用しているはずです。 Hereはそのためのチュートリアルです。

+0

私は古いUnityチュートリアルに従ったように見えます。あなたの助けをありがとう! – Fusion

関連する問題