-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display compatible custom resources when editing a Resource property in the inspector #34828
Display compatible custom resources when editing a Resource property in the inspector #34828
Conversation
cb8c3ae
to
e0908e1
Compare
I rebased recently, and it's still working! |
I spoke a little too soon. After some testing, I found out that although compatible resources appear in the list, they do not instance yet. I'll turn this PR into a draft instead and continue working on it. |
e0908e1
to
389f9c7
Compare
My current solution works on the 3.2 branch, but now an error message is printed when a custom resource is instantiated through the inspector. I'm having difficulties testing this on the 4.0 branch due to its instability, but I'm certain my solution isn't working there. I'm able to instance a custom type with this function:
But it must not be what I think it is, because it cannot cast to Resource:
Hopefully I can figure it out after some debugging. Edit: |
I got it working on 3.2 without errors! There is however one edge case I've found. Some resources have sub-resources, like materials in meshes for example. For some reason, the base_type is in reverse order for sub-resources, meaning I can't use get_slice() to reliably get the base type, and thus can't reliably instance the custom resource. |
eff423a
to
90d68d4
Compare
I fixed my edge case by not using get_slice(). Now, I record what base resource the custom resource inherits and instance that directly. If this passes the checks, I'll rebase and make this ready to review. |
36d9bc5
to
7f46a09
Compare
…e types Fix issue regarding the display of resources when editing resource properties.
7f46a09
to
3b7b02d
Compare
I rebased recently, and have moved functionality to the new EditorResourcePicker class. Although I can successfully populate the menu with the appropriate items, I can not instantiate them without crashing the editor. It looks like #48201 fixes the crash I'm experiencing, but my PR will likely need to be updated again once #48201 is merged. |
This seems closely related to #48201 and related PRs, CC @willnationsdev. I'm assuming it might be superseded by some of the newer/recently updated PRs but it would be good to check. |
I believe this was superseded by #62413, and the linked issue has already been resolved. |
Superseded by #62413. Thanks for the contribution nonetheless! |
Fixes #31591
When the user adds a custom resource via a GDScript plugin, their resource will now be displayed in the pop up menu when editing a compatible Resource property.
One limitation of my solution however is that it does not display children of custom resources. The solution I have in mind for that issue is a bit messy: find children of each custom type already found, and then find their children until no more children are found.
I'm actually not sure how to make a custom resource that derives from another custom resource through a GDScript plugin, so I can't set up a test project right now. If anyone knows how, I'd appreciate some guidance.