Skip to content

Fix UseToStringAsLabel on SubclassSelector attribute#99

Open
jhodk wants to merge 1 commit intomackysoft:mainfrom
jhodk:fix/use-to-string-as-label
Open

Fix UseToStringAsLabel on SubclassSelector attribute#99
jhodk wants to merge 1 commit intomackysoft:mainfrom
jhodk:fix/use-to-string-as-label

Conversation

@jhodk
Copy link

@jhodk jhodk commented Mar 6, 2026

Description

I am using unity editor version 6000.3.7f1.
The property UseToStringAsLabel on the SubclassSelector attribute does not currently appear to have any impact on the GUI render.

According to this code on the current main branch, we would expect the foodThree example field to be rendered in the editor with label "Grape".

// UseToStringAsLabel support on UNITY_2021_3_OR_NEWER
[SerializeReference, SubclassSelector(UseToStringAsLabel = true)]
public Food foodThree = new Grape();

However the left side of the screenshot below shows that is not the case - the name remains as "Food Three".

Changes made

  • Moved EditorGUI.BeginProperty calls after the label.text override.
  • Added ToString override in Food example class
  • Added list Foods Three to Example script with UseToStringAsLabel = true

Screenshots

Left is before the fix, Right is after the fix
image

Thanks.

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.

1 participant