- Home /
Custom tab of Terrain inspector, is it possible?
Hi all. I'm trying to implement some kind of tool for Unity Terrain which allows to configure 'moveability' of different areas of Terrain. I decided to create custom tab of Terrain inspector but faced a problem. The following simple script is starting point of my terrain inspector:
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor(typeof(Terrain))]
public class TerrainPassabilityEditor : Editor {
private Terrain Terrain;
private bool _drawDefaultInspector;
private bool _drawExtendedInspector;
void OnEnable()
{
Terrain=(Terrain)target;
}
void OnInspectorGUI()
{
GUI.enabled = true;
_drawDefaultInspector = GUILayout.Toggle(_drawDefaultInspector, "Default Inspector", EditorStyles.toolbarDropDown);
if (_drawDefaultInspector) DrawDefaultInspector();
_drawExtendedInspector = GUILayout.Toggle(_drawExtendedInspector, "Passability", EditorStyles.toolbarDropDown);
if (_drawExtendedInspector) DrawExtendedInspector();
}
private void DrawExtendedInspector()
{
GUILayout.Label("Passability of terrain");
}
}
It is placed to 'Assets/Editor' folder of my project. When unity editor compiles this script terrain inspector looks like this:
As you can see common terrain tools (height, textures, etc.) disappeared for some reason, and my custom inspector not shown also. What I'm doing wrong? Is it possible to create custom tab in terrain inspector?
Thanks in advance.
You need public override void OnInspectorGUI
to show your custom inspector. I tried a few things but couldn't get the terrain tools to show up...
Your answer
![](https://koobas.hobune.stream/wayback/20220613113313im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to get variables of the script show in unity editor/inspector? 2 Answers
How do I implement Draggable Properties with custom Labels in Editor or PropertyDrawer? 1 Answer
How can "bounds" for script variables be defined for use in the Inspector? 2 Answers
Hide public field on base class but show it on derived class 1 Answer