Skip to content

Instantly share code, notes, and snippets.

@ahmed-shariff
Created December 12, 2024 22:03
Show Gist options
  • Select an option

  • Save ahmed-shariff/c6969ea656e1b87addce7614be71b426 to your computer and use it in GitHub Desktop.

Select an option

Save ahmed-shariff/c6969ea656e1b87addce7614be71b426 to your computer and use it in GitHub Desktop.
Drawing the default inspector while ignoring some of the properties
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