Example #1
0
    string pushedButton(DTL_CATEGORY op)
    {
        string generateScript = GenerateDTLTemplate(op.ToString());

        switch (op)
        {
        case DTL_CATEGORY.PerlinIsland:
            generateScript += $"    public int depth = {depth}\n";
            generateScript += $"    public int frequency = {frequency}\n";
            generateScript += $"    public int octaves = {octaves}\n";
            generateScript += "    private Terrain terrain = GetComponent<Terrain>();\n\n";
            generateScript += "    private PerlinIsland perlinIsland = new PerlinIsland(frequency, octaves, maxHeight)\n";
            generateScript += "    public List<Texture2D> texture2D = new List<Texture2D>();\n\n";
            generateScript +=
                "    TerrainUtil terrainUtil = \n    new TerrainUtil(terrain, texture2D, perlinIsland, height, width, depth);\n";
            generateScript += "    terrainUtil.Draw();\n}";
            break;

        default:
            // do nothing
            break;
        }

        return(generateScript);
    }
Example #2
0
    void OnGUI()
    {
//        ShowHeaderImage();

        GUILayout.Label(topLabel, EditorStyles.boldLabel);
        dtlOptions = (DTL_CATEGORY)EditorGUILayout.EnumPopup("Dungeon", dtlOptions);

        GUILayout.Label(hwLabel, EditorStyles.boldLabel);
        width  = EditorGUILayout.IntField("width", width);
        height = EditorGUILayout.IntField("height", height);

        GUILayout.Space(spacePixel);

        switch (dtlOptions)
        {
        case DTL_CATEGORY.PerlinIsland:
            depth     = EditorGUILayout.IntField("depth", depth);
            frequency = EditorGUILayout.IntField("frequency", frequency);
            octaves   = EditorGUILayout.IntField("octaves", octaves);
            break;
        }

        // コードを生成、dungeonScriptにコードを挿入
        if (GUILayout.Button("Generate"))
        {
            dungeonScript  = "";
            dungeonScript += pushedButton(dtlOptions);
        }

        GUILayout.Space(spacePixel);

        GUILayout.Label(templateLabel, EditorStyles.boldLabel);
        scroll        = EditorGUILayout.BeginScrollView(scroll);
        dungeonScript = EditorGUILayout.TextArea(dungeonScript, GUILayout.Height(position.height / 2));
        EditorGUILayout.EndScrollView();
    }