godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.07k stars 69 forks source link

Add an inspector context menu option to copy the concatenated node and property path #8575

Open MIfoodie opened 7 months ago

MIfoodie commented 7 months ago

Describe the project you are working on

Would be helpful in any project.

Describe the problem or limitation you are having in your project

The problem is when you need to reference the property of a node in the script of a different node by copying and pasting. Currently if you are trying to do this, you have to copy the node path and the property path separately which could be annoying if you have to reference many properties.

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

My proposed feature would streamline this by adding another option when you right-click a property called "Copy Full Path". This would copy the full path to the property which would be in the format of

$[Path to node].[path to property]

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

if user right-clicks on a node's property:
      show options ["Copy Value", "Paste Value", "Copy Property Path", "Copy Full Property Path", "Open Documentation"]
      if user selects option("Copy Full Property Path"):
            add_to_clipboard( $[Path to node].[path to property] )

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

I think this enhancement would be used often enough.

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

I'm not sure if an add-on can this (I don't make add-ons so I wouldn't know, correct me if I'm wrong)do

supernovafiles commented 7 months ago

This looks interesting, I agree that this would be a nice feature.

timothyqiu commented 7 months ago

The problem is when you need to reference the property of a node in the script of a different node by copying and pasting.

I'm not sure what is the use case here.

Also, isn't auto completion much faster than selecting a node, right clicking a property, clicking a menu item, then pasting it in the script editor?

MIfoodie commented 7 months ago

Also, isn't auto completion much faster than selecting a node, right clicking a property, clicking a menu item, then pasting it in the script editor?

Yes, it probably would be, but having the ability to right-click to copy the property path is sort of useless without the node path so we might as well add to that feature to make it more useful.

unacomn commented 4 months ago

A feature like this would be useful for beginners as myself, at the very least copying a property path from the Inspector should copy its entire path relative to the node it's in. So, for example, copying the "text" property from a Text Mesh MeshInstance3D object just plumps out "text" as its path currently. That's a bit confusing to a beginner, as it should be ".mesh.text" for it to work.