Unity Terrain Texture Swap...how to?

Hi 3 scenarios:

  1. I have one texture, a map covering whole terrain-no tiling. Can I by script swap that entire texture for another also with no tiling? How would I do that?

  2. say I am using 3 or four splatmaps, can I swap one of these out for another texture at runtime also? so ingame I can swap out grass for dirt for example?

  3. can you use a greyscale mask to define where certain splatmaps are painted?

Many thanks AC

I am currently using the following function, but it does not seem efficient enough, so i am also looking for a better solution.

// Load specified texture and only that texture in given terrain
void LoadTerrain(TerrainData terrain_data, int texture_level) {

	float[, ,] alphas = terrain_data.GetAlphamaps(0, 0, terrain_data.alphamapWidth, terrain_data.alphamapHeight);

	// make sure every grid on the terrain is modified
	for (int i = 0; i < terrain_data.alphamapWidth; i++) {
		for (int j = 0; j < terrain_data.alphamapHeight; j++) {

			// make sure only set layer is visible
			for (int k = 0; k < terrain_data.alphamapLayers; k++) {
				if (k == texture_level) {
					alphas[i, j, k] = 1;
				} else {
					alphas[i, j, k] = 0;
				}
			}
		}
	}

	// apply the new alpha
	terrain_data.SetAlphamaps(0, 0, alphas);
}

a little upgraded script that allows to change texture without full repainting, e.g. it saves paint map and changes texture.