void OnGUI()
    {
        MadGUI.Info("To create a generator, implement IMadLevelGenerator interface and place your script in any Editor folder.");

        if (generators.Count == 0)
        {
            MadGUI.Error("I cannot found any generator in your project. Please implement at least one!");
            return;
        }

        chosenGeneratorIndex = EditorGUILayout.Popup("Generator", chosenGeneratorIndex, generators.ToArray());

        MadLevelConfiguration conf = MadLevelConfiguration.GetActive();

        chosenGroupIndex = EditorGUILayout.Popup("Group", chosenGroupIndex, GroupNames(conf));

        scene = EditorGUILayout.ObjectField("Scene", scene, typeof(Object), false);

        levelsCount = EditorGUILayout.IntField("Level Count", levelsCount);

        GUI.enabled = scene != null;
        if (MadGUI.Button("Create"))
        {
            string generatorName = generators[chosenGeneratorIndex];
            Type   generatorType = Type.GetType(generatorName + ", Assembly-CSharp-Editor");
            var    generator     = Activator.CreateInstance(generatorType) as IMadLevelGenerator;

            MadLevelConfiguration.Group group;
            if (chosenGroupIndex == 0)
            {
                group = conf.defaultGroup;
            }
            else
            {
                group = conf.groups[chosenGroupIndex - 1];
            }

            for (int i = 1; i <= levelsCount; ++i)
            {
                MadLevelConfiguration.Level level = conf.CreateLevel();
                level.sceneObject = scene;
                level.groupId     = group.id;
                level.type        = MadLevel.Type.Level;
                level.order       = int.MaxValue;
                level.name        = generator.GetLevelName(i);
                level.arguments   = generator.GetLevelArguments(i);
                conf.levels.Add(level);
                conf.SetDirty();
            }

            EditorUtility.SetDirty(conf);
        }
    }
 public LevelItem(MadLevelConfiguration configuration) {
     this.level = configuration.CreateLevel();
 }
 public LevelItem(MadLevelConfiguration configuration)
 {
     this.level = configuration.CreateLevel();
 }