Exemple #1
0
    // level part gui
    private void OnGUI_LevelPart()
    {
        var levelTitle = Enumerable.Range(0, levelData.LevelCount)
                         .Select(x => x.ToString()).ToArray();

        levelViewVector = GUILayout.BeginScrollView(
            levelViewVector, false, false,
            GUILayout.MinWidth(300 / (int)EditorGUIUtility.pixelsPerPoint),
            GUILayout.MaxWidth(400 / (int)EditorGUIUtility.pixelsPerPoint));

        levelIndex = GUILayout.SelectionGrid(
            levelIndex, levelTitle, 1);
        GUILayout.FlexibleSpace();

        if (GUILayout.Button("Add"))
        {
            levelData.AddLevel();
        }

        if (GUILayout.Button("Delete"))
        {
            if (levelData.LevelCount == 0)
            {
                return;
            }
            levelData.DeleteLevel(levelIndex);
            levelIndex = levelIndex == 0 ? 0 : levelIndex - 1;
        }

        GUILayout.EndScrollView();
    }