Skip to content
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

Custom C# Resource types made through add_custom_type are missing from inspector create resource menu #75245

Open
Atlinx opened this issue Mar 23, 2023 · 6 comments

Comments

@Atlinx
Copy link
Contributor

Atlinx commented Mar 23, 2023

Godot version

4.0.1.stable.mono.official

System information

Windows 11

Issue description

I have a plugin that registers C# resources with EditorPlugin.AddCustomType as a workaround to #27470. However the registered resources now don't show up in the create resource menu within the inspector

(In the gif below, I've registered two resources called AlphaResource and BetaResource but none of them show up)

broken

I suspect it might have something to do with how GDScript resources are getting first class support while C# resources still have yet to receive it.

Steps to reproduce

  1. Create C# plugin and a custom C# resource
  2. Add the custom C# resource type using EditorPlugin.AddCustomType
  3. Create a C# node script and export a "Resource".
  4. Rebuild the solution.
  5. Add the node script to a node
  6. Try to create a resource within the exported field by clicking on the empty slot.

Minimal reproduction project

https://github.com/Atlinx/Godot-Mono-CustomResourceRegistry

@RedworkDE
Copy link
Member

This issue basically gets obsoleted by #72619.

@raulsntos
Copy link
Member

The add_custom_type API and global classes are 2 different APIs.

The add_custom_type API is kind of deprecated and could be replaced with global classes, it was kept as a fallback for languages that don't implement global class support yet (such as C#). I don't think GDScript types registered with this API work either, so it's not an issue exclusive to C#.

@Zylann
Copy link
Contributor

Zylann commented Aug 3, 2023

This still happens in 4.1.1, and in GDScript too. It's not just a C# issue.

add_custom_type alone makes the resource appear in the New Resource dialog, but doesn't appear in dropdowns.
class_name alone makes the resource appear in dropdown, but not in the New Resource dialog.

So I end up using both at once...

@raulsntos
Copy link
Member

@Zylann class_name resources should be appearing in both:

MyResource dropdown Create New Resource
MyResource dropdown MyResource Create New Resource

MyResource.gd is a very simple class that extends from Resource, maybe your class has a more complicated hierarchy. Consider opening a new issue for this since this one is about add_custom_type.

@Zylann
Copy link
Contributor

Zylann commented Aug 4, 2023

@raulsntos my class has no complicated hierarchy, it directly extends Cubemap. However it is under res://addons, in case that matters.
I guess this would mean #78400 ?

@raulsntos
Copy link
Member

Yes, classes under res://addons are hidden when the addon is not enabled, but it seems the condition has a bug. So it's likely you are hitting the same bug.

alessandrofama added a commit to alessandrofama/godot that referenced this issue Jan 12, 2024
The icons of custom resources created with `class_name` and annotated with `@icon` or GDExtensionen resources that have an icon specified in the .gdextension file are not appearing in the `EditorResourcePicker`.  The problem is that the `EditorResourcePicker` retrieves the editor theme icon for the resource type and defaults to the `Object` icon if the type wasn't found. This will apply both to `class_name` and GDExtension resources.

This solution addresses the issue by replacing the usage of `Control::get_editor_theme_icon` with `EditorNode::get_class_icon` to ensure the correct icon is retrieved for the resource. Additionally, this fix removes the `custom_resources` lookup above that call, as these resources, added through `EditorPlugin::add_custom_type`, were not being included in the allowed types within `_add_allowed_type` in the `EditorResoucePicker`. Currently, these particular custom resources are never displayed in the picker. The related issue is logged here: godotengine#75245.

Fixes godotengine#86072.
GuybrushThreepwood-GitHub pushed a commit to GuybrushThreepwood-GitHub/godot that referenced this issue Jan 27, 2024
The icons of custom resources created with `class_name` and annotated with `@icon` or GDExtensionen resources that have an icon specified in the .gdextension file are not appearing in the `EditorResourcePicker`.  The problem is that the `EditorResourcePicker` retrieves the editor theme icon for the resource type and defaults to the `Object` icon if the type wasn't found. This will apply both to `class_name` and GDExtension resources.

This solution addresses the issue by replacing the usage of `Control::get_editor_theme_icon` with `EditorNode::get_class_icon` to ensure the correct icon is retrieved for the resource. Additionally, this fix removes the `custom_resources` lookup above that call, as these resources, added through `EditorPlugin::add_custom_type`, were not being included in the allowed types within `_add_allowed_type` in the `EditorResoucePicker`. Currently, these particular custom resources are never displayed in the picker. The related issue is logged here: godotengine#75245.

Fixes godotengine#86072.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants