You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem or limitation you are having in your project
When creating custom classes using class_name I almost always give them a name that is similar to their scripts file name.
Precisely speaking, I first come up with the class name say MyClass then I create a script my_class.gd and write there class_name MyClass.
Doing this often can be a bit annoying considering this could be automated.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The idea is use autocompletion for that.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
When a script my_class.gd is created, I just could type cla and then autocompletion could appear with the custom class name based on the script name, that is class_name MyClass could be suggested in this case.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Well, you just could write class name manually every time, or you could somehow copy-paste script file name and then change it to PascalCase. But this is not convinient.
Is there a reason why this should be core and not an add-on in the asset library?
Solving the problem using autocompletion with a plugin (al least with gdscript one) is not available now, because there is no API for working with autompletion.
But I can see some options of how to solve it:
a plugin that adds class_name MyClass line to current script; this would be hacky due to lack of exposed ScriptEditor API (for example this one)
a plugin that creates a script by class name (it opens a popup where you specify the class name MyClass, and when confirmed, it creates a script in the folder selected in the filesystem dock, with name my_class.gd and adds class_name MyClass line there); this could be fine, but this may be inconvenient / not enough if you have already created a script and only then decided to make it a custom class
However despite the possibility of creating a plugin that solve the problem, I find it useful to have this in core.
The text was updated successfully, but these errors were encountered:
Would love to see this added (if it isn't implemented somewhere already). I can't actually think of any downside to implementing this. Folks who don't want class names to automatically be added can just leave the field blank.
This is a good idea, but IMO better overall UX would be to not require typing the name at all. The Create Script window could have another checkbox/toggle to automatically create a class name (or [GlobalClass] in C#). If the Named class checkbox is checked, this script would be created with the first line class_name NewScript extends Node.
There used to be a class name option in the script creation dialog, but it was removed in 4.2 as it was a read-only field that was always N/A when using GDScript:
Describe the project you are working on
Editor plugins (gdscript)
Describe the problem or limitation you are having in your project
When creating custom classes using
class_name
I almost always give them a name that is similar to their scripts file name.Precisely speaking, I first come up with the class name say
MyClass
then I create a scriptmy_class.gd
and write thereclass_name MyClass
.Doing this often can be a bit annoying considering this could be automated.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
The idea is use autocompletion for that.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
When a script
my_class.gd
is created, I just could typecla
and then autocompletion could appear with the custom class name based on the script name, that isclass_name MyClass
could be suggested in this case.If this enhancement will not be used often, can it be worked around with a few lines of script?
Well, you just could write class name manually every time, or you could somehow copy-paste script file name and then change it to PascalCase. But this is not convinient.
Is there a reason why this should be core and not an add-on in the asset library?
Solving the problem using autocompletion with a plugin (al least with gdscript one) is not available now, because there is no API for working with autompletion.
But I can see some options of how to solve it:
class_name MyClass
line to current script; this would be hacky due to lack of exposedScriptEditor
API (for example this one)MyClass
, and when confirmed, it creates a script in the folder selected in the filesystem dock, with namemy_class.gd
and addsclass_name MyClass
line there); this could be fine, but this may be inconvenient / not enough if you have already created a script and only then decided to make it a custom classHowever despite the possibility of creating a plugin that solve the problem, I find it useful to have this in core.
The text was updated successfully, but these errors were encountered: