Exemplo n.º 1
0
    private void ShowMapSelectMenu()
    {
        EditorGUILayout.Space();

        if (selectedCreateType == MapDataType.Map)
        {
            EditorGUILayout.LabelField("Create New Map");

            newMapName = EditorGUILayout.TextField(newMapName);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Create"))
            {
                var newMap = CreateInstance(typeof(MapDatabaseObject)) as MapDatabaseObject;
                newMap.name = newMapName;

                mapDatabase.mapDatabaseDictionary.Add(newMap.name, newMap);
                mapDatabase.Save();

                AssetDatabase.AddObjectToAsset(newMap, mapDatabase);
                EditorUtility.SetDirty(mapDatabase);

                currentMap = newMap;

                selectedCreateType = MapDataType.None;
            }

            if (GUILayout.Button("Cancel"))
            {
                selectedCreateType = MapDataType.None;
            }
            GUILayout.EndHorizontal();

            return;
        }

        if (GUILayout.Button("Create New Map"))
        {
            selectedCreateType = MapDataType.Map;
        }

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Map List");
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        foreach (var map in mapDatabase.mapDatabaseObjects.OrderBy(m => m.name))
        {
            if (GUILayout.Button(map.name))
            {
                map.InitDictionary();
                currentMap = map;

                RefreshMap();
            }
        }
    }