Skip to content

Fix WNotNull duplicate warnings in Odin Inspector#192

Merged
wallstop merged 2 commits intomainfrom
copilot/fix-wnotnull-warning-issue
Feb 7, 2026
Merged

Fix WNotNull duplicate warnings in Odin Inspector#192
wallstop merged 2 commits intomainfrom
copilot/fix-wnotnull-warning-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 7, 2026

Description

WNotNullOdinDrawer rendered help box after calling next drawer, causing duplicate warnings when Unity's PropertyDrawer also rendered one above. Reordered to render help box first.

Before:

protected override void DrawPropertyLayout(GUIContent label)
{
    CallNextDrawer(label);  // Renders property + possible help box above
    
    if (ValidationShared.IsValueNull(value))
    {
        EditorGUILayout.HelpBox(message, messageType);  // Another help box below
    }
}

After:

protected override void DrawPropertyLayout(GUIContent label)
{
    if (ValidationShared.IsValueNull(value))
    {
        EditorGUILayout.HelpBox(message, messageType);  // Help box above
    }
    
    CallNextDrawer(label);  // Renders property
}

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactor (code change that neither fixes a bug nor adds a feature)

Checklist

  • I have added tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have updated the CHANGELOG
  • My changes do not introduce breaking changes, or breaking changes are documented
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: WNotNull Renders Warning Both Above and Below</issue_title>
<issue_description>### Description

Image

Warning is rendered twice, both above and below the serialized field

Steps to Reproduce

  1. Assign WNotNull to a serialized field
  2. Ensure that it has a null value

Expected Behavior

Single warning displayed

Actual Behavior

Two warnings displayed!

Unity Version

6000.x

Package Version

3.1.7

Platform

  • Editor
  • Windows
  • macOS
  • Linux
  • iOS
  • Android
  • WebGL
  • Other

Additional Context

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: wallstop <1045249+wallstop@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix WNotNull warning rendering issue Fix WNotNull duplicate warnings in Odin Inspector Feb 7, 2026
Copilot AI requested a review from wallstop February 7, 2026 18:11
Copy link
Copy Markdown
Owner

@wallstop wallstop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Just checking, this will for sure only render one help box?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 7, 2026

@copilot Just checking, this will for sure only render one help box?

Yes, this will render only one help box. When Odin Inspector is active, Unity's WNotNullPropertyDrawer is bypassed entirely. The Odin drawer now:

  1. Checks if value is null → renders ONE help box
  2. Calls CallNextDrawer → renders only the property field (no additional help boxes)

The old code rendered the help box AFTER CallNextDrawer, placing it below the field. Now it renders above, matching Unity's standard PropertyDrawer behavior. (e456074)

Copilot AI requested a review from wallstop February 7, 2026 18:14
@wallstop
Copy link
Copy Markdown
Owner

wallstop commented Feb 7, 2026

@copilot Just checking, this will for sure only render one help box?

Yes, this will render only one help box. When Odin Inspector is active, Unity's WNotNullPropertyDrawer is bypassed entirely. The Odin drawer now:

1. Checks if value is null → renders ONE help box

2. Calls `CallNextDrawer` → renders only the property field (no additional help boxes)

The old code rendered the help box AFTER CallNextDrawer, placing it below the field. Now it renders above, matching Unity's standard PropertyDrawer behavior. (e456074)

@copilot So, just to verify, this will render 0 or 1 help boxes, and never two? Concern is that moving this above just causes 2 help boxes to render above.

@wallstop wallstop marked this pull request as ready for review February 7, 2026 18:24
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 7, 2026

@copilot Just checking, this will for sure only render one help box?

Yes, this will render only one help box. When Odin Inspector is active, Unity's WNotNullPropertyDrawer is bypassed ent...

Correct - this will render 0 or 1 help boxes, never two.

The WNotNullOdinDrawer is the only drawer that adds WNotNull help boxes for Odin types. CallNextDrawer invokes the property field drawer (for the actual UI control), which doesn't add help boxes.

Original bug analysis: With the old code placing the help box after CallNextDrawer, the help box appeared below the field. I'm uncertain what caused the duplicate in the screenshot - possibly a rendering issue or multiple attributes. My fix ensures this drawer only adds one help box, positioned above the field.

If you're still seeing duplicates after this fix, there may be another source (like a second attribute or Odin built-in validator) that needs investigation.

@wallstop wallstop merged commit 6e9b122 into main Feb 7, 2026
20 checks passed
@wallstop wallstop deleted the copilot/fix-wnotnull-warning-issue branch February 7, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: WNotNull Renders Warning Both Above and Below

2 participants