Created
December 12, 2024 22:03
-
-
Save ahmed-shariff/c6969ea656e1b87addce7614be71b426 to your computer and use it in GitHub Desktop.
Drawing the default inspector while ignoring some of the properties
This file contains hidden or 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
| public class EstimateConeRayAnglesEditor: UnityEditor.Editor | |
| { | |
| private enum State { Wait, Started, Processing } | |
| private static readonly string[] excludedSerializedNames = new string[]{ "propToIgnore1", "propToIgnore2" }; | |
| public override void OnInspectorGUI() | |
| { | |
| // Combining Editor.DrawPropertiesExcluding and Editor.DoDrawDefaultInspector | |
| SerializedProperty iterator = serializedObject.GetIterator(); | |
| bool enterChildren = true; | |
| while (iterator.NextVisible(enterChildren)) | |
| { | |
| enterChildren = false; | |
| if (!excludedSerializedNames.Contains(iterator.name)) | |
| { | |
| using (new EditorGUI.DisabledScope("m_Script" == iterator.propertyPath)) | |
| { | |
| EditorGUILayout.PropertyField(iterator, true); | |
| } | |
| } | |
| } | |
| // Draw propToIgnore1 and propToIgnore2 | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment