Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Unity HideInNormalInspector attribute
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <http://unlicense.org/>.
/// @purpose: HideInNormalInspector attribute, to hide fields in the normal Inspector but let them show in the debug Inspector.
/// @why: Because this functionality should be built-into Unity.
/// @usage: Add `[HideInNormalInspector]` as an attribute to public fields you'd like hidden when Unity's Inspector is in “Normal” mode, but visible when in “Debug” mode.
/// @intended project path: Assets/Plugins/EditorUtils/HideInNormalInspectorAttribute.cs
/// @interwebsouce: https://gist.github.com/capnslipp/8138106
using UnityEngine;
public class HideInNormalInspectorAttribute : PropertyAttribute {}
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <http://unlicense.org/>.
/// @purpose: HideInNormalInspector attribute, to hide fields in the normal Inspector but let them show in the debug Inspector.
/// @why: Because this functionality should be built-into Unity.
/// @usage: Add `[HideInNormalInspector]` as an attribute to public fields you'd like hidden when Unity's Inspector is in “Normal” mode, but visible when in “Debug” mode.
/// @intended project path: Assets/Plugins/Editor/EditorUtils/HideInNormalInspectorDrawer.cs
/// @interwebsouce: https://gist.github.com/capnslipp/8138106
using UnityEngine;
using UnityEditor;
[CustomPropertyDrawer(typeof(HideInNormalInspectorAttribute))]
class HideInNormalInspectorDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) {
return 0f;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment