Пример #1
0
    private void OnGUI()
    {
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, false);

        GUIContent[] layersOptionsMenu = new GUIContent[4];
        layersOptionsMenu[0] = new GUIContent("Ground");
        layersOptionsMenu[1] = new GUIContent("Biome");
        layersOptionsMenu[2] = new GUIContent("Alpha");
        layersOptionsMenu[3] = new GUIContent("Topology");

        EditorGUI.BeginChangeCheck();
        layerIndex = GUILayout.Toolbar(layerIndex, layersOptionsMenu, EditorStyles.toolbarButton);
        if (EditorGUI.EndChangeCheck())
            TerrainManager.ChangeLayer((TerrainManager.LayerType)layerIndex, TerrainTopology.TypeToIndex((int)layers.Topologies));

        if (layerIndex != (int)TerrainManager.CurrentLayerType)
            layerIndex = (int)TerrainManager.CurrentLayerType;

        switch ((TerrainManager.LayerType)layerIndex)
        {
            case TerrainManager.LayerType.Ground:
                Functions.TextureSelect(TerrainManager.CurrentLayerType, ref layers);
                Functions.AreaSelect();
                Functions.LayerTools(TerrainManager.CurrentLayerType, TerrainSplat.TypeToIndex((int)layers.Ground));
                Functions.RotateTools(TerrainManager.CurrentLayerType);
                Functions.RiverTools(TerrainManager.CurrentLayerType, TerrainSplat.TypeToIndex((int)layers.Ground), ref aboveTerrain);
                Functions.SlopeTools(TerrainManager.CurrentLayerType, TerrainSplat.TypeToIndex((int)layers.Ground), ref slopesInfo);
                Functions.HeightTools(TerrainManager.CurrentLayerType, TerrainSplat.TypeToIndex((int)layers.Ground), ref heightsInfo);
                break;
            case TerrainManager.LayerType.Biome:
                Functions.TextureSelect(TerrainManager.CurrentLayerType, ref layers);
                Functions.AreaSelect();
                Functions.LayerTools(TerrainManager.CurrentLayerType, TerrainBiome.TypeToIndex((int)layers.Biome));
                Functions.RotateTools(TerrainManager.CurrentLayerType);
                Functions.RiverTools(TerrainManager.CurrentLayerType, TerrainBiome.TypeToIndex((int)layers.Biome), ref aboveTerrain);
                Functions.SlopeTools(TerrainManager.CurrentLayerType, TerrainBiome.TypeToIndex((int)layers.Biome), ref slopesInfo);
                Functions.HeightTools(TerrainManager.CurrentLayerType, TerrainBiome.TypeToIndex((int)layers.Biome), ref heightsInfo);
                break;
            case TerrainManager.LayerType.Alpha:
                Functions.LayerTools((TerrainManager.LayerType)layerIndex, 0, 1);
                Functions.AreaSelect();
                Functions.RotateTools((TerrainManager.LayerType)layerIndex);
                Functions.RiverTools((TerrainManager.LayerType)layerIndex, 0, ref aboveTerrain, 1);
                Functions.SlopeTools((TerrainManager.LayerType)layerIndex, 0, ref slopesInfo, 1);
                Functions.HeightTools((TerrainManager.LayerType)layerIndex, 0, ref heightsInfo, 1);
                break;
            case TerrainManager.LayerType.Topology:
                Functions.TopologyLayerSelect(ref layers);
                Functions.AreaSelect();
                Functions.LayerTools(TerrainManager.CurrentLayerType, 0, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.RotateTools(TerrainManager.CurrentLayerType, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.TopologyTools();
                Functions.RiverTools(TerrainManager.CurrentLayerType, 0, ref aboveTerrain, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.SlopeTools(TerrainManager.CurrentLayerType, 0, ref slopesInfo, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.HeightTools(TerrainManager.CurrentLayerType, 0, ref heightsInfo, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                break;
        }
        EditorGUILayout.EndScrollView();
    }