Godot version:
5a5614e
Issue description:
When selecting a node that has a script the "Attach Script" icon switched to "Clear Script", now it doesn't:
How it's supposed to look:
Byproduct of #20233, now the add-script button would automatically populate the "extends" field to the path of the script.
CC @willnationsdev
Yes, I specifically brought this up with reduz, and he said that he would rather the clear script button go away entirely instead of showing both it AND the add script button. You still have access to clearing a script from the right-click context menu and from the Inspector's "script" property and it was an infrequent-enough operation that he thought that would be acceptable.
I guess the question remains: is there enough public outcry over this change that people want to show both of the icons at once?
Why must the "Add script" be shown when there's already a script though?
Because clicking the add script button on a node that already has a script now auto-fills the inherits field of the ScriptCreateDialog, for easier creation of derived scripts. This is especially useful for deriving from script classes, which can be inherited from by name.
So if a node has script A attached, you click the "Add script" again, it will propose to create a new script B to replace the attached A, which inherits from A?
That seems a bit weird usability wise to me, I'm not sure it's a good design. At least it's not the workflow I would expect when I want to attach a script to a node that should inherit a base script.
That's the functionality I would have expected. Would you expect there to be a separate button created with a new icon, that conditionally shows up instead of the add script button, but does the same thing? So basically just change the icon?
I don't know, I just came back from holidays and maybe need to test the feature before criticizing ;)
As is I don't really see why the "common" use case for scripts inheriting another script would be to have the base script assigned first, and then replace that, instead of adding the new script directly without having to assign this base script before.
I understand the potential workflow if you have e.g. a base enemy.tscn with enemy.gd, and you create an inherited scene bat.tscn where you want to attach bat.gd that inherits enemy.gd - but is that really the main workflow for this feature?
@akien-mga
As is I don't really see why the "common" use case for scripts inheriting another script would be to have the base script assigned first, and then replace that, instead of adding the new script directly without having to assign this base script before.
It isn't meant to replace that workflow. It's about adding another workflow that just didn't exist before. If you have a script on a node already, and you want to extend it with another script, you can still do it the same way you did it before, but you have to add an extra step to clear the script beforehand which is cumbersome since you then have to go back and find the exact path of the old script (which could be buried deeply in a plugin - although script classes help with this).
Now, this common, but more complex pattern can be turned into...
It doesn't have any impact on the no-script case, so it's a huge workflow improvement for that case. However, I can definitely understand if people want to bring back the clear script button as well. People are used to it, and it may actually be more useful for beginner users who might be confused about a clear script button not existing.
Edit:
This also makes using plugins MUCH more intuitive when combined with script classes. I "add a node" to my scene (opens dialog), click on a script class defined by a plugin's script, and then immediately click on the "add script" button to derive it and create my own unique behavior, exactly as I would do with an in-engine class.
Right, I'm starting to understand the workflow, especially when it comes to "custom nodes" where you'd add them to the scene tree with an existing "base" script that you'd want to inherit. Given this, I think it's fine to lose the "clear script" button, which was likely not that useful (convenient for testing stuff when debugging the engine, but maybe not so much when actually developing games).
As such it's not a bug as it's the expected behaviour. Now the question remains on whether the usability is "good enough" or if we want the clear script behaviour back. I see two options:
I'd tend towards keeping what we have for now and see what other feedback we get from users, and we can reevaluate then.
I think the icon and tooltip should change when in "inherit" mode.
Also, when I try to use it, it just says that the inherited parent name/path is invalid.
Oh, well that is definitely a bug. XD
Inherit script icon could use something like this instead of a +
Yeah, I know akien proposed changing the icon when deriving. I'm not sure who "approves" visual designs like that though.
CC @djrm
IMO it had more intuitive behavior in 3.0.6 than now in 3.1...
@Chaosus Yeah, I would've just kept them both personally, but it's not my call.
I prefer the old behavior (and I remember cherry-picking this feature for the 2.1 branch), but the new workflow also looks interesting so I would opt for the second option:
Keep the "add script"/"clear script" toggle, and add an additional button when selecting a node with an existing script with this "inherit script" icon.
As such it's not a bug as it's the expected behaviour. Now the question remains on whether the usability is "good enough" or if we want the clear script behaviour back. I see two options:
- Reuse the "add script" button for this new "inherit existing script" feature, getting rid of the "clear script" button. This is what was proposed by @reduz and is implemented, and after thinking about it I think it may be good enough. The only question is whether it would be worth it to make the "inherit existing script" behaviour clearer to the user (e.g. with by changing the icon to one which should it would be inheriting the script instead of adding a new one).
- Keep the "add script"/"clear script" toggle, and add an additional button when selecting a node with an existing script with this "inherit script" icon.
I'd tend towards keeping what we have for now and see what other feedback we get from users, and we can reevaluate then.
whatever the new feature is. A new 'corner icon' should be design for that new feature, instead of "green plus sign" which already has other meaning. I think assigning a new behavior to a existed button without any appearance change is puzzling. A same 'file icon' with a different 'corner icon' will be much better than current behavior of Godot 3.1 alpha. The GUI explains itself.
@JustusPan I agree. I'm not sure what the workflow is to add new icons to the editor though. Has something to do with creating an SVG, optimizing it with a utility, and then adding it to /editor/icons. But then there's also the godot-design
repository and idk how that's involved.
@akien-mga Speaking of which, @PLyczkowski created an icon and forwarded it to me. I have added an optimized copy of the .svg file to a godot-design branch of mine, but I'm not sure how I'm supposed to integrate that with the editor. Am I supposed to just submit a separate PR to update the /editor/icons
directory with the same .svg file?
I prefer the old behavior too. Inheriting a script is not common at all. The add script button here to "create a script that inherits the previous one and then replace it" has quite an unexpected behavior.
I would probably make this a RMB menu entry and either remove the button when the node has a script or bring back the delete script button.
Perhaps some people use it more than others then, cause I know it's an important feature for my use-cases. But a lot of people have been confused by the change, so either having both buttons or switching to a RMB option sounds pretty good.
It is very common for me. @groud Are you testing with the new icon? It should be pretty obvious then when you are adding a new script and when you are extending. But I'm ok with it being an RMB menu entry if it's confusing even with a separate icon.
@PLyczkowski The new icon isn't actually present yet. I have a branch on my godot-design repo with it, but I haven't heard back from anyone about what I'm actually supposed to do with the icon. The documentation on "adding icons to the editor" isn't really consolidated/clear.
I understand the confusion about the functionality then.
@PLyczkowski I'm going to submit a PR soon that adds the icon. We'll see what people think about it then. Don't even know if I'm doing it "right". <_< Just copy/pasting the optimized SVG to the editor/icons folder and hoping that does the trick...
The README seems understandable to me: https://github.com/godotengine/godot/blob/master/editor/icons/README.md
Make PR on the godot-design repo with the sources, optimize the SVG and put the optimized SVG in editor/icons
.
The README seems understandable to me: https://github.com/godotengine/godot/blob/master/editor/icons/README.md
Make PR on the godot-design repo with the sources, optimize the SVG and put the optimized SVG in editor/icons
.
(git log editor/icons
can also give you some hints :))
@akien-mga Oh, a README in /editor/icons
, of course! I checked around godot-design, but didn't understand how any of the stuff was so supposed to tie back into the main godot repo. Feels stupid now
Sounds like my guess turned out to be right then, lol. Thanks!
@akien-mga It doesn't actually close the issue though. It just adds an extends icon so that we can test whether people are satisfied with that or if they still want the old button setup.
Well, you did that :)
Oh, does putting "close" in it automatically close it?? TIL...whoops. I'll keep that in mind.
I'll have to google if there's a list of keywords like that and be more mindful in the future. Thanks for the heads-up.
@willnationsdev I agree with @groud . I am using Godot extensively and refactoring is way slower without a fast way to clear a script.
Most helpful comment
I prefer the old behavior too. Inheriting a script is not common at all. The add script button here to "create a script that inherits the previous one and then replace it" has quite an unexpected behavior.
I would probably make this a RMB menu entry and either remove the button when the node has a script or bring back the delete script button.