Exemplo n.º 1
0
    private void DrawLeftSide()
    {
        int y = Offset;

        GUI.Label(new Rect(Offset, y, 180, LineHeight), "Level Name:");
        y += LineHeight;
        if (WorldData == null)
        {
            GUI.Label(new Rect(Offset, y, 180, LineHeight), "Create NEW or LOAD world!");
        }
        else
        {
            WorldData.WorldName = GUI.TextField(new Rect(Offset, y, 150, LineHeight), WorldData.WorldName);
        }
        y += LineHeight + Offset;

        WorldData = (IsometricWorldData)EditorGUI.ObjectField(new Rect(Offset, y, 180, LineHeight), WorldData, typeof(IsometricWorldData), false);
        y        += LineHeight + Offset;

        int   numberOfButtons = 2;
        float button_width    = (LeftWidth - (numberOfButtons + 1) * Offset) / numberOfButtons;

        if (GUI.Button(new Rect(Offset, y, button_width, LineHeight), "NEW"))
        {
            SaveWorld();
            EnterNameWindow.Open("Enter world name:", CreateNewWorld);
        }
        EditorGUI.BeginDisabledGroup(WorldData == null);
        if (GUI.Button(new Rect(Offset * 2 + button_width, y, button_width, LineHeight), "DELETE"))
        {
            AssetDatabase.DeleteAsset(WorldDataPath + WorldData.name + ".asset");
            WorldData = null;
            SaveWorld();
        }
        EditorGUI.EndDisabledGroup();
        y += LineHeight + Offset;


        EditorGUI.BeginDisabledGroup(true);
        if (GUI.Button(new Rect(Offset, y, button_width, LineHeight), "LOAD"))
        {
            //TODO
        }
        EditorGUI.EndDisabledGroup();

        EditorGUI.BeginDisabledGroup(WorldData == null);
        if (GUI.Button(new Rect(Offset * 2 + button_width, y, button_width, LineHeight), "SAVE"))
        {
            SaveWorld();
        }
        EditorGUI.EndDisabledGroup();
        y += LineHeight + Offset;

        GUI.Box(new Rect(0, y, LeftWidth, LineWidth), "");
        y += Offset;
    }
Exemplo n.º 2
0
    private void CreateNewWorld(String name)
    {
        WorldData           = new IsometricWorldData();
        WorldData.WorldName = name;
        IsometricTilePrefabController    initialBlock = TileSetsData.EmptyTile;
        List <IsometricTileData>         line         = new List <IsometricTileData>();
        List <List <IsometricTileData> > row          = new List <List <IsometricTileData> >();
        IsometricTileData tile = new IsometricTileData(initialBlock, 0);

        line.Add(tile);
        row.Add((line));
        WorldData.SetTileData(row);
        AssetDatabase.CreateAsset(WorldData, WorldDataPath + name + ".asset");
        SaveWorld();
    }