godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.14k stars 94 forks source link

Add an option to copy the actual property path in the inspector right-click menu #10970

Open Ignawesome opened 20 hours ago

Ignawesome commented 20 hours ago

Describe the project you are working on

A project with heavily nested use of resources and tweens modifying properties from those resources

Describe the problem or limitation you are having in your project

Currently, getting the property path for a property heavily nested in resources is pretty unintuitive.

For example: I have a GPU particles node with a mesh in draw_pass_1, which has a material which has an albedo_color.

In order to create a tween that modulates the alpha in that albedo_color, I need the following path: path_to_node:draw_pass_1:material:albedo_color:a

Autocomplete does not work unless you create and assign a typed variable for each step, i.e.:

var mesh : Mesh = path_to_node.draw_pass_1
var material : Material = mesh.material #(sidenote, I don't know why there is no autocomplete for this)
var color : Color = material.albedo_color

However, there is a feature in the inspector that seems like it could help but doesn't. Right-clicking the property name and selecting "Copy Property Path" does not yield the path at all, but the property name. So, in the above example, with the inspector showing the GPUParticles, I first need to right-click draw_pass_1, click on copy, paste to the script, repeat for every step needed. This approach requires understanding how the full path works, otherwise there will be an error at runtime in the case of tweens.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I propose adding a new button to the right click menu that gives you the full path from the node currently selected in the inspector. In the example above, the full path would be ":draw_pass_1:material:albedo_color" In this way, user error and confusion about required paths is mitigated.

Furthermore, it could be argued that this is what the current "Copy Property Path" button would appear to do. Right now, that button only returns the name of the property, rather than a path to the property.

In terms of naming, I see two options:

  1. Keeping "Copy Property Path" button name and adding "Copy Full Property Path" below it.
  2. Changing "Copy Property Path" to "Copy Property Name" and adding "Copy Property Path" as this feature I'm proposing here.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

I don't know how the code works, or how much work it is, but here is a mockup. inspector godot proposal

The keyboard shortcut could be discussed here. I haven't used the ones currently implemented, as they need a left click to work anyway.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I actually have no idea if there is a way to code this, but the current engine implementation could be better.

Is there a reason why this should be core and not an add-on in the asset library?

This is about improving the built-in inspector.

KoBeWi commented 16 hours ago

In order to create a tween that modulates the alpha in that albedo_color, I need the following path: path_to_node:draw_pass_1:material:albedo_color:a

You can do tween_property($PathToNode.draw_pass_1.material, "albedo_color:a", i.e. use the material as target, not its parent node.