Skip to content

Instantly share code, notes, and snippets.

@Q-Bert-Reynolds
Created May 7, 2015 03:53
Show Gist options
  • Save Q-Bert-Reynolds/e03b9e8b2fbc186ef189 to your computer and use it in GitHub Desktop.
Save Q-Bert-Reynolds/e03b9e8b2fbc186ef189 to your computer and use it in GitHub Desktop.
getting the unity terrain brush size
// to get the terrain brush size in an editor script
EditorPrefs.GetInt("TerrainBrushSize")
// if you need to get the terrain brush size from a non-editor script (monobehaviour)
System.Type editorPrefs = System.Type.GetType("UnityEditor.EditorPrefs, UnityEditor", false, false);
System.Type[] paramTypes = new System.Type[]{ typeof(string) };
System.Reflection.MethodInfo method = editorPrefs.GetMethod(
"GetInt",
BindingFlags.Public | BindingFlags.Static,
null,
paramTypes,
null
);
int terrainBrushSize = (int)method.Invoke(null, new string[]{"TerrainBrushSize"});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment