Skip to content

Allow [ShowIf] and [HideIf] to check for null#10133

Closed
boxrocket6803 wants to merge 1 commit intoFacepunch:masterfrom
boxrocket6803:hide-if-null
Closed

Allow [ShowIf] and [HideIf] to check for null#10133
boxrocket6803 wants to merge 1 commit intoFacepunch:masterfrom
boxrocket6803:hide-if-null

Conversation

@boxrocket6803
Copy link
Copy Markdown
Contributor

@boxrocket6803 boxrocket6803 commented Mar 6, 2026

Summary

HideIfAttribute (and by extension ShowIfAttribute) previously wouldn't function when using null as the value, now they do.

image

Motivation & Context

slight annoyance, easy fix

Implementation Details

The entire SerializedObject was being passed into SerializedProperty.GetValue(object defaultValue) as the default (such that if the properties value was null it would check against the serialized object rather than the property and always return false). I'm assuming this to be unintentional.

Checklist

  • Code follows existing style and conventions
  • No unnecessary formatting or unrelated changes
  • Public APIs are documented (if applicable)
  • Unit tests added where applicable and all passing
  • I’m okay with this PR being rejected or requested to change 🙂

Copilot AI review requested due to automatic review settings March 6, 2026 02:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates conditional inspector visibility attributes to correctly support null comparisons when evaluating against SerializedObject, aligning [HideIf] / [ShowIf] behavior with expected “value is null” checks in the Editor inspector.

Changes:

  • Stop passing the SerializedObject instance as the defaultValue to SerializedProperty.GetValue<T>(), allowing null property values to remain null.
  • Ensure [HideIf] / [ShowIf] can match Value == null as intended.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@handsomematt handsomematt added the triaged triaged pull-requests are replicated on the internal sbox repo label Mar 25, 2026
@sboxbot sboxbot added the accepted this pull request was accepted, hurrah! label Apr 7, 2026
@sboxbot
Copy link
Copy Markdown
Contributor

sboxbot commented Apr 7, 2026

This PR has been merged upstream.

@sboxbot sboxbot closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted this pull request was accepted, hurrah! triaged triaged pull-requests are replicated on the internal sbox repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants