Hi
Using some reflection and editorscripts I have built a utility which can show the hidden functions in Unity, and I have found a lot of great stuff which I don’t understand why it isn’t documented.
There is all this with the terrain system, and why it isn’t documented, but I will leave that since there are reasons for keeping it undocumented.
Here are instead some other goodies:
-
Built in perlin noise : Yes Unity have built in perlin noise, it works really great too:
Mathf.PerlinNoise (float x, float y); -
OnPreviewSettings and OnPreviewGUI:
Want to be able to show fancy previews of your ScriptableObjects (custom made assets) like the ones for previewing textures and models.
Now you can, simply add the function OnPreviewGUI to your editor script.
public void OnPreviewGUI (Rect r) {
GUI.Box (r,"Hello\nThis is my custom preview");
}
There is a function called OnPreviewSettings which you can implement too, but I’m not sure what it does.
- And some terrain stuff anyway:
TerrainData.lightmap : The terrain lightmap
Terrain.GetSteepness (float x,float y) : I haven’t tried this but I guess it returns the angle of the terrain.
UnityEditor.TerrainLightmapper.Generate (Vector3 terrainPosition, TerrainData terrainData, TerrainCollider collider, Light[ ] lights, Color ambient, int shadowSamples, Texture2D lightmap, Texture2D shadowMap);
This generates a lightmap for the terrain, not very usefull, but anyway.
TerrainLightmapper.SuperSampleShadowOffset (float shadowSize, int shadowSamples);
Returns an array of Vector3s randomly distributed (can be some order in it to make it not too random), good if you need to anti-alias something.
- UnityEditor.InternalEditorUtility.HasPro () : Have you forgot if you have pro or the free version? No problem! Just call this to find out.
But no, there is no function called ActivatePro
You can also check if you have got the Unity Beta:
UnityEditor.InternalEditorUtility.IsUnityBeta ();
- EditorGUILayout.ToolbarSearchField (string text);
This is something I think UT should have documented, it shows a search field like the one you use in the project view to search for assets.
Unfortunately that function is hidden (private), but using some reflection you can call it anyway
using UnityEngine;
using System.Collections;
using UnityEditor;
using System.Reflection;
using System;
[CustomEditor(typeof(MyScript))]
public class MyEditor : Editor {
public string search = "Hello";
public override void OnInspectorGUI () {
System.Object[] parameters = new System.Object[2] {search, new GUILayoutOption [0]};
search = (string)DoInvoke (typeof(EditorGUILayout),"ToolbarSearchField",parameters);
}
public static System.Object DoInvoke (Type type,string methodName, System.Object[] parameters) {
Type[] types = new Type[parameters.Length];
for (int i=0;i<parameters.Length;i++) {
types[i] = parameters[i].GetType ();
}
MethodInfo method = type.GetMethod (methodName,(BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public),null,types,null);
return DoInvoke2 (type,method, parameters);
}
public static System.Object DoInvoke2 (Type type, MethodInfo method, System.Object[] parameters) {
if (method.IsStatic) {
return method.Invoke (null,parameters);
}
System.Object obj = type.InvokeMember(null,
BindingFlags.DeclaredOnly |
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.CreateInstance, null, null, new System.Object[0]);
return method.Invoke(obj,parameters);
}
}
There’s a lot more you can do, but I can’t list everything here.
Remember that all undocumented features are not fully supported, meaning that an update of unity or the webplayer can break any use of those features.

