Last active
April 12, 2022 09:39
-
-
Save capnslipp/8138106 to your computer and use it in GitHub Desktop.
Unity HideInNormalInspector attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @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
That's very interesting, but caution, it won't show elements in the editor with
SerializedProperty
serializedObject
PropertyField
, which is interesting to use with the new prefab workflow. Do you have any idea for a workaround?