Beispiel #1
0
    void Start()
    {
        terr            = (Terrain)GetComponent(typeof(Terrain));
        terr.name       = "Terrain";
        Tw              = terr.terrainData.heightmapWidth;
        Th              = terr.terrainData.heightmapHeight;
        heightMapBackup = terr.terrainData.GetHeights(0, 0, Tw, Th);
        initHeightMap   = terr.terrainData.GetHeights(0, 0, Tw, Th);

        for (int i = 0; i < Tw; i++)
        {
            for (int j = 0; j < Th; j++)
            {
                initHeightMap[i, j] = 0;               //desiredHeight;//desiredHeight;
            }
        }

        Debug.Log("START TERRAIN");
        terr.terrainData.SetHeights(0, 0, initHeightMap);

        Debug.Log(terr.detailObjectDistance.ToString());
        Terrain.activeTerrain.detailObjectDistance = 10000;
        Terrain.activeTerrain.basemapDistance      = 1000;
        //terr.detailObjectDistance = 1000;
        instance = this;
        //generateTerrain.instance.UpdateTerrainHeight(0, 0, 8.0f);
        //generateTerrain.instance.UpdateTerrainHeight(128, 128, 8.0f);
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        generateTerrain myScript = (generateTerrain)target;

        if (GUILayout.Button("Generate Terrain"))
        {
            myScript.Start();
        }
    }
Beispiel #3
0
    void Start()
    {
        terr = (Terrain) GetComponent(typeof(Terrain));
        terr.name = "Terrain";
        Tw = terr.terrainData.heightmapWidth;
        Th = terr.terrainData.heightmapHeight;
        heightMapBackup = terr.terrainData.GetHeights(0, 0, Tw, Th);
        initHeightMap = terr.terrainData.GetHeights(0, 0, Tw, Th);

        for (int i=0; i<Tw; i++)
        {
            for (int j=0; j<Th; j++)
            {
                initHeightMap[i,j] = 0;//desiredHeight;//desiredHeight;
            }
        }

        Debug.Log("START TERRAIN");
        terr.terrainData.SetHeights(0,0,initHeightMap);

        Debug.Log(terr.detailObjectDistance.ToString());
        Terrain.activeTerrain.detailObjectDistance = 10000;
        Terrain.activeTerrain.basemapDistance = 1000;
        //terr.detailObjectDistance = 1000;
        instance = this;
        //generateTerrain.instance.UpdateTerrainHeight(0, 0, 8.0f);
        //generateTerrain.instance.UpdateTerrainHeight(128, 128, 8.0f);
    }