Open DexterFstone opened 3 months ago
It sounds like you want to be able to create an extension class in GDScript (a Script that acts like it is a new class). Seems like a duplicate of #7950 to me
It sounds like you want to be able to create an extension class in GDScript (a Script that acts like it is a new class). Seems like a duplicate of #7950 to me
here are more details about my proposal
Having a GDScript behave the same as an native class would be a bit tricky, but I think for the two issues you pointed out there might be simpler solution:
addons
folder2. Clicking on a method, property, or signal opens the script, not the documentation: For example, I create a class called
CustomCharacterBody2D
and publish it. Someone wants to use it but cannot access its APIs directly because it is not the root. Or maybe they want to see what this method does when they click on it, so they go directly to the script instead of the documentation.
I think we should separate the Open Documentation and Go to Definition shortcuts. For example, Ctrl+Click and Ctrl+Shift+Click (or Alt+Click). Both options would be available for GDScript. For native symbols, we can support documentation only or implement opening the sources on GitHub in the browser (I'm not sure how difficult it is to implement).
Describe the project you are working on
Projects and Add-ons that Use Custom Classes
Describe the problem or limitation you are having in your project
When creating a custom class:
CustomCharacterBody2D
and publish it. Someone wants to use it but cannot access its APIs directly because it is not the root. Or maybe they want to see what this method does when they click on it, so they go directly to the script instead of the documentation.Describe the feature / enhancement and how it helps to overcome the problem or limitation
Adding a @read_only Keyword to Custom Classes in Godot (Of course, I am not sure about the name @read_only) In Godot, the @read_only keyword can be added to the top line of a custom class script to achieve several beneficial behaviors:
Prevent Direct Node Editing: When a node with a @read_only script is added to a scene, the script button in the node's scene window is hidden. This prevents direct editing of the script's code, promoting a more structured and maintainable approach.
Enable Script Attachment: Despite being read-only, nodes with @read_only scripts can still have other scripts attached to them. This allows for extending the functionality of the read-only script using separate scripts, promoting code modularity and reusability.
Method and Signal Documentation: Clicking on methods, signals, or properties of a @read_only script will directly open the script's documentation instead of the script code. This enhances the user experience by providing immediate access to relevant documentation.
Clean Node Display: In the "Add Node" window, the script name is hidden from the node name for @read_only scripts. This aligns with the behavior of internal Godot nodes, creating a consistent and intuitive node naming convention.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
If this enhancement will not be used often, can it be worked around with a few lines of script?
no
Is there a reason why this should be core and not an add-on in the asset library?
there is currently no built-in API in Godot to directly achieve the desired behavior of making custom classes read-only with the specified features. Implementing these features would require modifications to the Godot engine's core code.