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

Create dialog does not show global classes from addons inside subfolders #78400

Closed
FreshlyBrewedCode opened this issue Jun 18, 2023 · 3 comments · Fixed by #91337
Closed

Create dialog does not show global classes from addons inside subfolders #78400

FreshlyBrewedCode opened this issue Jun 18, 2023 · 3 comments · Fixed by #91337

Comments

@FreshlyBrewedCode
Copy link

FreshlyBrewedCode commented Jun 18, 2023

Godot version

4.1.beta1.mono

System information

Godot v4.1.beta1.mono - macOS 13.3.1 - Vulkan (Forward+) - integrated Apple M1 Pro - Apple M1 Pro (8 Threads)

Issue description

The new GlobalClass attribute for registering global types in C# (#72619) does not seem to work in nested addons, i.e. addons that are placed within a subfolder of the addons directory (res://addons/**/<addon>).
Placing addons inside of subfolders is supported accroding to #43734

Edit: as confirmed by @raulsntos the same problem is present for GDScript.

Detailed showcase of the problem

Given the following project:
image

Where the CustomProjectNode.cs, CustomAddonNode.cs, and CustomSubfolderAddonNode.cs are implemented like this:

using Godot;

namespace Addon;

[GlobalClass]
public partial class CustomAddonNode : Node
{
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
    }

    // Called every frame. 'delta' is the elapsed time since the previous frame.
    public override void _Process(double delta)
    {
    }
}

And both addons are enabled in the project settings, the CustomSubfolderAddonNode does not show up when adding a new node:
image

Steps to reproduce

  1. Create a new project
  2. Create a new C# addon
  3. Create a node with the GlobalClass attribute
  4. Move the folder containing the addon to a subfolder inside of addons
  5. Compile the C# project
  6. Enable the addon inside the project settings
  7. Try to add the custom node to a scene. The node does not show up in the search

Minimal reproduction project

GlobalClassTest.zip

@raulsntos
Copy link
Member

In the MRP you have uploaded, you can see in .godot/global_script_class_cache.cfg that the 3 classes are recognized and have been added to the list of global classes.

This feels like the issue is in the Editor code that determines which classes should be added to the dialog. To confirm I have ported the MRP to GDScript and I am able to reproduce this so it doesn't seem exclusive to C#. This is why we usually ask users to provide a GDScript MRP even for C# issues, it allow us to confirm if it's a C# issue or if the issue may be somewhere else.

The issue is likely in this condition in the create_dialog:

if (!EditorNode::get_singleton()->is_addon_plugin_enabled(script_path.get_slicec('/', 3))) {

GDScript MRP: GlobalClassTestGDScript.zip

@FreshlyBrewedCode
Copy link
Author

FreshlyBrewedCode commented Jun 18, 2023

Thank you for pointing that out. I did not think of porting to GDScript.
Also, I just checked and the same problem occurs when creating instances of custom resources. I assume that would also be covered by the line you mentioned above since it is using the same dialog?

btw should we rename the issue?

@raulsntos
Copy link
Member

Also, I just checked and the same problem occurs when creating instances of custom resources. I assume that would also be covered by the line you mentioned above since it is using the same dialog?

Yes, it's likely the same cause.

btw should we rename the issue?

Oh yeah, feel free to rename it to something more appropiate now that we know it's also happening with GDScript's class_name.

@FreshlyBrewedCode FreshlyBrewedCode changed the title C# [GlobalClass] does not work in nested addons Create dialog does not show global classes from addons inside subfolders Jun 18, 2023
AyOhEe added a commit to AyOhEe/Godot-VR-Body-Solver that referenced this issue Nov 11, 2023
These should now appear in  the Create Node dialog. They don't, but this is an editor bug (godotengine/godot#78400 )
@akien-mga akien-mga added this to the 4.3 milestone Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants