The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

0 votes

I am currently trying new features of version 4.1 (.net). A particularly nice one is the new [GlobalClass] attribute that makes C# classes available in the node selection.

Unfortunately, this does not work here, for example:

public interface IEntity { }

[GlobalClass]
public partial class Entity : Node { }

[GlobalClass]
public partial class EntityCharacterBody2D : CharacterBody2D, IEntity { }

[GlobalClass]
public partial class EntityNode2D : Node2D, IEntity { }

No class appears in the node selection, even after restarting the editor.

Before I open a bug, I wanted to ask if anyone has had other experiences?

I am working on Win11 with Visual Studio Community 2022 version 17.6.4

Godot version 4.1
in Engine by (18 points)

1 Answer

0 votes

Hello, for me it's working correctly. Just in case, did you build your c# project after adding [GlobalClass] to your class? And, have you tried to find your class when selecting a node using the search function? I was in a test project when I tried this new functionality, at first I also could not find where my class marked as global is located, but after a few minutes of searching with my eyes, I found it in a completely non-obvious place, not where it should be according to inheritance logic. However, after a few more tests, I figured out that if you have two classes A and B, with class A inherits from some Godot Node, and class B from class A, and at the same time class B is marked as GlobalClass and A is not, then class B in the node selection will appear at the top level of the selection nodes, along with Viewport, CanvasItem and others. However, if both classes A and B are labeled as Global Class, then they will appear in the node selection hierarchy with the correct inheritance chain

by (75 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.