Improve drag and drop into array property editors#102534
Improve drag and drop into array property editors#102534Repiteo merged 6 commits intogodotengine:masterfrom
Conversation
|
Custom Resource Array gets highlighted for CustomResource.gd, even though it doesn't (and shouldn't) accept it. O8sr887BVQ.mp4 |
|
@KoBeWi Great find! But that bug is also present in the current master, not caused by this PR 😁 In fact, you can also drag I'll see if I can find out why that happens and contribute a fix |
|
Correction: it does need some work in this PR because I copied the faulty logic into The cause is this bit here: godot/editor/editor_resource_picker.cpp Lines 689 to 692 in 36d90c7 I'm not sure what the purpose of that code is. The bug happens because For now, I'll add another commit to this PR that fixes the bug in the least invasive way possible, and also modify the commit where I copied the bug to the |
4e6d4fc to
7e84479
Compare
|
Should all be fixed now, please take another look. FYI, I would rather not squash these commits together, because each of them can stand on its own. If any regressions are introduced, bisecting and focused reverting is easier this way. |
5a09650 to
3ec3d2c
Compare
This was already done for Resource properties; this just makes things consistent.
See discussion on godotengine#102534. Before this fix, it was possible to drag a file `CustomResource.gd` with `class_name CustomResource` onto a property of type `CustomResource`. Of course, the intention is that only `Resource`s with the `CustomResource` script attached are accepted. (Actually accepting the script, but creating a resource from it automatically, is left as a future improvement.)
This duplicates some of the logic in EditorResourcePicker, but that's unavoidable: EditorResourcePicker works on a single, loaded resource, whereas we'd like this to be efficient and not need to load all (potentially many) dragged resources. Instead, we use the EditorFileSystem cache to get the information we need. Note that EditorResourcePicker also supports some automatic conversions, such as from Shader to ShaderMaterial. This change does not attempt to make that work for arrays as well.
For example, an Array[MyScript] property now accepts any node with the script MyScript on it. This works for Node and NodePath arrays alike, and also with the @export_node_path annotation.
The most common scenario is dragging a file from the filesystem dock, which drags it as type "file", not "resource". This already worked. This change also makes it possible to drag a resource from another property editor.
Instead of having to first click the button, then drag the item into the new slot, this allows just dragging the item onto the button directly. The button is highlighted as a valid drop target to signal this.
3ec3d2c to
93d342b
Compare
|
Rebased onto master, fixed conflicts with b9a6057. Now that the dust has settled on the 4.4 release, I guess this is ready to merge? |
|
Needs squash before this can be merged |
Each of them could even have been a separate PR, but the overhead didn't seem worth it. Still want me to squash? |
Repiteo
left a comment
There was a problem hiding this comment.
On second thought, nah. The squashing isn't a hard-rule, and doesn't need to be enforced when you've done such a good job at making atomic commits. We'll ship it as-is!
|
Thanks! |
|
adding a red tone on fields that cant accept it would be a plus |
I think it's better to draw attention to properties that can be interacted with, but you can always open a proposal! |
This makes a couple of things work that you'd expect to work:
+ Add Elementbutton. The button is highlighted to indicate this.Further details and rationale for implementation can be found in the individual commit messages.
Fixes godotengine/godot-proposals#6862, which currently has 33 upvotes and no objections.
CC @YuriSizov who brought this up on Mastodon.
Demo video:
dragdrop.mp4
Test project:
dragdroptest.zip