-
-
Notifications
You must be signed in to change notification settings - Fork 22k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better custom EditorPlugin nodes #6067
Comments
I don't understand what you mean |
@reduz when you add to the scene a node which a type created by a plugin, it already has the plugin script attached. So it's impossible to add another script with custom behavior. |
Of course not, this is by core design and will not change. On Aug 7, 2016 18:11, "George Marques" notifications@github.com wrote: @reduz https://github.com/reduz when you add to the scene a node which a — Reply to this email directly, view it on GitHub |
This is sad. But you can always add the script to the parent or to a child. Closing as wontfix. |
I may be misunderstanding something, but if your custom type is a script, On Aug 7, 2016 9:52 PM, "George Marques" notifications@github.com wrote:
|
I guess it would need the ability of having two (or more) scripts per node, though this really does not make much sense. |
Godot orginally supported this, but it was more trouble than advantage On Aug 7, 2016 10:36 PM, "George Marques" notifications@github.com wrote:
|
The problem is that custom nodes are next to useless as they aren't really "custom nodes", they're just base nodes with a pre-set script and different icon. I guess back to the scene to inherit + script to extend combo then. |
Well, being a preset node with a pre-set script and a different icon is IMO On Mon, Aug 8, 2016 at 10:40 AM, Dominik Banaszak notifications@github.com
|
I'd love if it could be automated/made easier through the UI. |
As I understand it the expectation is to have the possibility to create custom nodes that will behave like built-in nodes, i.e. they should have the following features:
That would be the "natural" expectation when declaring a custom node, and would be a very powerful feature; I gather from the above that it does not work this way so far, partly due to design decisions. If there's a way to have a functionality such as what I described above, I'm pretty sure it would have a lot of applications. The assetlib would be full of custom nodes that do a lot of work out of the box and can be used as if they were built-in. Reopening until there's a consensus on what can/should be done or not. |
+1 |
Please explain in which way you believe they do not On Aug 8, 2016 11:50 AM, "Ralf Hölzemer" notifications@github.com wrote:
|
As already said previously, the biggest drawback at the moment is that custom types are little more than a quick way of instancing the base type of that script and assign the appropriate script to that instance. This makes extending that node in the editor with another script impossible - like you can do with built in types. But it is also impossible to build inheritance trees with custom nodes in the "Create new Node/Resource" dialogs because they only show up in these trees when you register them with a built in type as a parent via add_custom_type. For example, lets assume I want to inherit all my custom types in my project from a single base type. base.gd
type_a.gd
type_b.gd
As it is right now, I have to register those types like this. In this case, the second argument of add_custom_type has to be "Node", otherwise they won't show up in the dialogs.
... and this is the result. While it is nice to be able to register custom types like this, the dialogs don't reflect the nature of the inheritance of those types like other built in types. For any built in type, I can look at that tree and see at a glance what I am dealing with. I can, for example, be sure that Sprite is a Node2D and therefor inherits all of the functions provided by Node2D. The same is not true for custom types. Now, if custom types could be fully registered into the global scope, like @akien-mga mentioned above, things would be much simpler to understand and use. First, you could inherit from a custom type referenced by type name instead of the file path/name. base.gd
type_a.gd
type_b.gd
... then, the registration of the custom types could be simplified like this. Note the missing second parameter of add_custom_type.
... and you would get a much nicer overview in the "Create new Node/Resource" dialogs: ... and of course the ability to extend those types in the editor with a custom script: ... which would also be referenced by type name instead of the script name/path
Here's the example plugin from above to play around. |
Oh I see.. these two thigs should definitely be fixable, together with On Aug 8, 2016 1:54 PM, "Ralf Hölzemer" notifications@github.com wrote:
|
What will never happen is scripts dissapearing from the instanced nodes, or On Aug 8, 2016 2:02 PM, "Juan Linietsky" reduzio@gmail.com wrote:
|
@reduz It seems to me a rather clumsy way of indicating a custom type and I think nobody would come up with the idea that by replacing the current script on a node, you get a script that extends the script that was already there. That's just not the way extending via script works for the base types. And what would happen if the user clears that script field? Does the custom type revert back to the previous script or does it completely revert back to the base type? Again, I don't think this would be a good idea. Instead, it could just be indicated as a custom type in the node tree or the properties editor via different color, some icon or something else, without sacrificing the empty script slot. |
The point here is that the script that defines the custom node should be hidden, because it's not a property of the instanced node but of its type. So this script should confer properties to the custom node, but it should be as invisible to the user of the instanced node as the C++ classes of built-in nodes are. It would provide an API, but would not be modifiable, only extend-able. Just like when you instance a Sprite, you don't get Now, I don't know if it's technically possible right now, but it would be the natural use case AFAIU. If you modify the script of the custom type, it would modify the type itself, and thus would impact all instances of this type. But the instanced nodes using the custom type should have their own script that |
I think that feature would need Object to have an additional pointer to the "base custom script type", because you need that information when you want to remove a user script from it (which should actually replace it by the base script). |
Actually, that pointer could not even be needed. Marking the script would be enough, for example if you add_custom_type() with a script, the engine can set a flag on the class so the information is available, as "hey, this script class is an engine type extension". Removing a user script would then replace it with the first inherited script class marked as "custom type", or remove it if there are none. |
Sorry, I am against hidding a script if the node has a script. What's the The fact it has a script does not mean the slot is busy or that it needs a What we can do, if you agree, is hide the script icon in the scene tree if On Aug 10, 2016 11:01 PM, "Marc" notifications@github.com wrote: Actually, that pointer could not even be needed. Marking the script would — Reply to this email directly, view it on GitHub |
@reduz I think that would be good enough 😄 |
@reduz I agree, and I didn't said we need a second script. I was just wondering what would happen if you add a script inheriting the first one (the custom defined by plugin), but then decide to remove it. It would then revert the node to a basic engine type without any script then? |
Just wanted to mention, as a new user of Godot, I made a plugin under the impression my "Custom Node" from the plugin would act as a builtin node. That is, when I selected it from the node list, I expected I would get a node without a script, but with the functionality I had scripted in the plugin being inherited already builtin (like it is for the builtin nodes). Just thought I should give another opinion from someone just coming in (though it looks like the discussion here has already been extensive). |
As a "custom node" is just a script what is even the difference from just assigning the script to a built in node? What is the custom node feature supposed to do? |
@MCrafterzz It was discussed that there should be the ability to custom nodes to have the ability to add a script over a custom node created from a plugin. Currently custom node is just a node created with a script already attached and icon and name already changed. |
@willnationsdev How far have you come by implementing this feature. I don't want to pressure anyone. So please don't take it the work way. |
I've been implementing a new backend for the custom type system entirely. The new one allows users to do all of the original functionality, plus making it so that the Add-a-Script button adds a new script which is extending the custom script by default (rather than opening the custom script) and makes it so that you cannot remove the custom script (you would have to use the Change Type editor command, just like any other engine type). |
In addition, it will allow users to register types to a global which provides access to typename-to-filepath mappings. GDScript will be able to perceive these mappings as essentially simple global typenames. Furthermore, types do not have to be custom types in order to be registered and the types can be either scripts or scenes. So far, I've gotten the new backend implemented and I've re-setup the original custom type script functionality. Currently will be working on new features. Starting a week from now probably. I'm otherwise busy this week. |
@willnationsdev No worries, if it makes into 3.1 I will be content. |
Currently, the editor does have the ability to easily extend any node's script: The node itself currently looks like this: And @reduz 's main concern was with hiding the fact that there is already a script attached. On one hand, it makes sense to not hide that from the user. But on the other hand, custom nodes are pretty much always going to have scripts attached. Without scripts, custom nodes are just existing regular nodes with custom icons and no extra functionality added. And even though you can extend the custom script, it's very annoying that plain custom nodes look the same as extended custom nodes. So, here's my simple solution: When a custom node's script is the same one as the script in the custom node's definition, the script icon should be faded out, like this: Meaning: |
Guys, real life example:If i have Many custom note of the same kind, each script customized for its own instance, what does happen if I want to change the base custom node script? I tell you: THE WORST, because I need to modify it, AND all of other instances accordingly, delivering high chance of human and typo errors. You dont want to hide script? Fine, then show the custom_node script AND the project node script. |
@aaronfranke In my opinion this is the best solution. Even instanced scenes could benefit from this. |
Implements godotengine#6067 (aaronfranke's idea) Fixes godotengine#26980
@zatherz et al, now that #30697 has been implemented, what else can be improved? Is there anything else in #6067 (comment) that is important to have? |
Implements godotengine#6067 (aaronfranke's idea) Fixes godotengine#26980
Closing as fixed by #30697. While the original proposal in the OP elaborated in #6067 (comment) has not been implemented, this won't happen due to @reduz's concerns in #6067 (comment). |
Nodes created by the
add_custom_type
function in EditorPlugin have the selected script assigned to it when adding. This makes them almost useless, as you can only use the functions defined in that script in other nodes.This is completely different from other nodes and makes node addons pretty much useless/much more annoying to use.
The text was updated successfully, but these errors were encountered: