Unity Code Reflection Script w/ UI - Examining Terrain/Data

I’ve put together a simple UI for examining GameObject, Terrain, and TerrainData, which can be useful for others.

In TerrainTest009.zip, I’ve created a new Scene. Added two textures. Added a terrain. Did some painting with the splats. And then added some C# code generation to examine the terrain script objects more closely. I added a little GUI so you don’t have to check the console output. And then zipped and placed here:
http://tagenigma.com/qa/Unity3d/TerrainTest009.zip

After all that, I just need a little assistance with the Terrain and TerrainData objects. I’m wondering, where is the actual paint data being stored? Is there an array of vectors somewhere storing the splats?

Your assistance is appreciated.

If you want to examine other objects, just drag TerrainScript onto your gameObject and the UI will open on start.

The TypeCheck meta data is foobar, so just right-click and reimport. After that it runs fine.

The idea is that the tool can show more information than you’ll find in the component reference docs:

Seeing that terrainData lacks any documentation:

Currently the UI supports querying the following:

this
gameObject
terrain
terrainData

Yielding results similar to the following:

// Autogenerated Init Code
UnityEngine.TerrainData terrainData = new UnityEngine.TerrainData();
terrainData.lightmap = new UnityEngine.Texture2D();
terrainData.lightmap.mipmapCount = 7;
terrainData.lightmap.format = DXT1;
terrainData.lightmap.width = 64;
...
(tons more)
...

Here we go.
http://forum.unity3d.com/viewtopic.php?t=10036

ApplySplatmap.js might use Terrain.GetAlphamaps and Terrain.SetAlphamaps to manipulate the splats. I’ll have to investigate further to make sure these are the diffuse splats and not the heightmaps.

Okay, I can’t have my pipeline depend on undocumented features.

So I’ll take a different tact. I hope it’s possible to dynamically create prefabs in that (EditorUtility.InstantiatePrefab) is documented. However, it’s a bit odd that it’s not in the UnityEngine.DLL so that’s probably the wrong way to go about it…
http://unity3d.com/support/documentation/ScriptReference/EditorUtility.InstantiatePrefab.html

Its in UnityEditor.dll

Sorry was dealing with other bugs and didn’t post sooner. Mike on the Chatzilla helped me instantiate prefabs by adding a property to my script to hold the prefab and then making the reference using the inspector on the gameObject.

public class BryceSceneScript : MonoBehaviour {

	public UnityEngine.Object _PrefabBryce = null;
	
	// Use this for initialization
	void Start () {
		
		for (int z = 0; z < 10; ++z)
		{
			for (int x = 0; x < 10; ++x)
			{
				if (null != _PrefabBryce)
				{
					UnityEngine.Object.Instantiate(_PrefabBryce, new Vector3(x*10, 0, z*10), Quaternion.identity);
				}
				else
				{
					UnityEngine.Debug.LogError("Prefab Object is null");
				}
			}
		}
	}
}

Now I’m onto some performance testing with Prefabs. I found an issue with OBJ/Uvs/materials that stumped me last night.
http://forum.unity3d.com/viewtopic.php?p=107304 The post includes a project that instances the prefabs with camera navigation.

Interesting. I get 4 FPS in a VM with no shader support. Hopefully there’s a fallback mechanism that I haven’t read about yet.

Something that will approximate what it should look like: