Home > Back-end >  The Name 'GUILayout' does not exist in the current context
The Name 'GUILayout' does not exist in the current context

Time:08-01

I'm doing procedural terrain generation in unity from Sebastian Lague's tutorial, and this code isn't working. How can I fix that?

using System.Collections;
using System.Collections.Generic;
using UnityEditor;

[CustomEditor (typeof(MapGenerator))]
public class MapGeneratorEditor : Editor {
    public override void OnInspectorGUI() {
        MapGenerator mapGen = (MapGenerator)target;

        DrawDefaultInspector ();

        if (GUILayout.Button ("Generate")) {
            mapGen.GenerateMap ();
        }
    }
}

CodePudding user response:

You should also include UnityEngine namespace

using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
  • Related