godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.12k stars 78 forks source link

Clearly show Scene Instance script reference override (add/remove/replace) on node with icon and/or different color #2976

Open hsandt opened 3 years ago

hsandt commented 3 years ago

Describe the project you are working on

I'm making an RPG based on the Godot Open RPG Template (https://github.com/GDquest/godot-open-rpg).

It uses script inheritance with PlayerInput extends BattlerAI and RandomAI extends BattlerAI, and relies on overwriting the base BattlerAI script with the specific PlayerInput or RandomAI script on instantiated character scenes.

Describe the problem or limitation you are having in your project

I am working with scene instances where I'm replacing some scripts with others on certain nodes coming from the scene template, and I tend to forget which scripts have been replaced, and which haven't. This is currently possible only by selecting the node, and opening the Script section in the Inspector. There, you can see in the script reference has been overridden with something else by checking the Revert icon (counter-clockwise arrow).

However, you can't tell at a glance by watching the node in the Scene tree panel, and the normal Script panel icon on the right of the node's name makes me think everything is normal. If you remove the script, then at least you can see that no script is attached, but you can't tell that a script was removed at a glance either.

In addition, the Script section starts folded so you need to unfold it to actually see the change.

Example

Before override, the original script coming from the scene template:

Godot 3 2 3 - script ref override - before overriding

After override:

Godot 3 2 3 - script ref override is not indicated by icon - only indicated in Inspector

The inspector with unfolded Script section shows the change, but the script icon on the right of the node stays the same.

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

We could indicate script reference overwrite on instantiated scene nodes with an icon, such as:

We could also change the color of the script icon itself, but we should not rely on color alone for accessibility.

Here are the existing icons in the contextual menu:

Godot 3 2 3 - script ref override - icon reference

You can also have a look at own Unity indicates component changes on prefab instances. It uses the same principle: new components are marked with a "+" icon, removed components with "-" and grayed out. There are never "changed components" because in Unity, objects can have multiple components. So if you change the component, you're actually removing the component from the prefab and adding a custom one.

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

A mockup using the Extend Script icon (this would replace the "After override" screenshot above):

Godot 3 2 3 - script ref override new icon mockup

It may be trickier to determine if the new script is a child of the original script though, so a generic "modified" script icon would be fine too.

For added and removed scripts, we'd have the same but using the green "+" and red cross icons.

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

I guess there could be some editor preference to always unfold the "script" section of the Inspector and even put it at the top, so the user can see which script is attached, and if it's different from the template scene node's script thanks to the Revert icon. That would actually be useful for other reasons (if the user doesn't remember which script is attached and doesn't want to hover on the Script icon, which is a bit slower).

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

It seems difficult to change the look of the Script icon in the Scene tree panel with an add-on.

Same thing with the workaround of moving the Inspector's Script section to the top and auto-unfold it.

hsandt commented 1 year ago

I also realized any indication of override could be combined with an actual button / right-click menu to revert or apply the override, as suggested in #4820. In this case, there is already a Revert button near the Script in the inspector, so we'd only need to apply/revert button in some contextual menu (more convenient since Script is at the bottom of the inspector). But I'll let this be handled along other overridden properties in said proposal.

hsandt commented 6 months ago

Got the same issue again today, for some reason I had added a script on my Scene asset but the Scene instance was overridden to clear the script (script = null in text resource, apparently happened when I played with the scene hierarchy) and the issue was invisible.

The red cross icon would help indicate that the script was removed compared to original scene. That said, looking at my own proposal I see that some icons are ambiguous whether they indicate a status or are actual buttons. For instance, red cross could mean "remove" rather than "removed".

Maybe the half-transparent script icon suggested in https://github.com/godotengine/godot-proposals/issues/3016 would be better for "removed", similarly to Unity prefab override removed components.

Other alternatives include a "minus" symbol, or "Removed" text but there is not much space in the scene tree so that'd have to go into the inspector panel.

References from Unity:

image