Skip to content

GenericPropertyDrawer cannot draw objects of serializable type #91

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Folorox opened this issue Sep 5, 2019 · 4 comments
Closed

GenericPropertyDrawer cannot draw objects of serializable type #91

Folorox opened this issue Sep 5, 2019 · 4 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@Folorox
Copy link

Folorox commented Sep 5, 2019

GenericPropertyDrawer cannot detect both the built-in property drawer and a user-written property drawer of a serializable type (a class with the [Serializable] attribute), and displays "No PropertyDrawer for type..." when drawn in a collection editor.

From what I can tell in the code, the built-in property drawer is not detected because serializable types are not considered as having it, and no custom property drawer is detected because only property drawers in the ScriptableObject-Architecture.Editor assembly are checked.

May be related to #7 and commit a31f77a.

@DanielEverland
Copy link
Owner

DanielEverland commented Sep 18, 2019

Sorry for the long wait, I completely forgot to respond 😬

It works as expected on my end
image

[System.Serializable]
public class TestClass
{
    [SerializeField]
    private float testValue;
}
[CustomPropertyDrawer(typeof(TestClass))]
public class TestClassPropertyDrawer : PropertyDrawer
{
    public override void OnGUI(Rect propertyRect, SerializedProperty property, GUIContent label)
    {
        EditorGUI.LabelField(propertyRect, "TEST");
    }
}

It's by-design that it can't draw the default inspector for your class, I can't recall why that is, it's been a while since I touched that bit of code, but it was probably too troublesome to support it while also handling all the other features the GenericPropertyDrawer contains.

@Folorox
Copy link
Author

Folorox commented Sep 24, 2019

Custom property drawers would only work if it was placed in the ScriptableObject-Architecture.Editor assembly though. For folks like me who use SO-A as a package in the package manager, we would not be able to put our custom property drawers among the read-only package files to make it visible to the GenericPropertyDrawer code.

Screenshot from 2019-09-24 16-33-55

@DanielEverland
Copy link
Owner

Ah, that would indeed not work. I'll look into finding another way of checking whether a property drawer exists :)

@DanielEverland
Copy link
Owner

Fixed in Release 1.6.2. It will now look at both the default editor assembly and also every assembly definition assembly, regardless of how it's imported
It's also been pushed to releases/stable

Thanks for the report! :)

@DanielEverland DanielEverland added the bug Something isn't working label Oct 19, 2019
@DanielEverland DanielEverland self-assigned this Oct 19, 2019
@DanielEverland DanielEverland added this to the Release 1.6.2 milestone Oct 19, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants