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
This feature would be general purpose for OOP practices.
Describe the problem or limitation you are having in your project
Current you have to override methods from another class without any error checking syntax highlighting for overridden functions. This works fine but in most cases an interface requires all methods to have implementations for whichever script extends them.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Have the ability to create interface class by specifying an @interface() annotation where you can optionally pass in callables that require implementations or leave blank to require all functions to be implemented.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
This would require a class_name to be registered otherwise the @interface annotation will be ignore.
Heres and example script that's annotated as an interface.
I think what you said is perhaps this: #6416, for GDScript trait in it, as what the thread-poster said, has an extra functionality that it supports extending a class so that you are allowed to define a function in a trait, while in interface you cannot define your functions but to only declare them.
What im thinking is that you still can add code to the functions if necessary and call it via super.activate() as it is now. but what im suggesting is to create an artificial error that prevents the code from running without the functions being implemented within any other scripts that extends them. But in addition to that it will also provide syntax highlighting such as when typing func _ready() for example.(technically that could be its own issue/feature)
Describe the project you are working on
This feature would be general purpose for OOP practices.
Describe the problem or limitation you are having in your project
Current you have to override methods from another class without any error checking syntax highlighting for overridden functions. This works fine but in most cases an interface requires all methods to have implementations for whichever script extends them.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Have the ability to create interface class by specifying an
@interface()
annotation where you can optionally pass in callables that require implementations or leave blank to require all functions to be implemented.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
This would require a class_name to be registered otherwise the
@interface
annotation will be ignore.Heres and example script that's annotated as an interface.
Now heres a script that extends the Tool script
If this enhancement will not be used often, can it be worked around with a few lines of script?
Currently you can override the functions without but this feature basically enables true interfaces in GDScript.
Is there a reason why this should be core and not an add-on in the asset library?
This would be a new annotation such as (
@export
,@onready
, etc) in the core of GDScript.The text was updated successfully, but these errors were encountered: