godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.98k stars 3.24k forks source link

GlobalClassAttribute in C# #8608

Open iRumba opened 11 months ago

iRumba commented 11 months ago

Your Godot version: 4.2 Stable Mono

Issue description: GlobalClassAttribute works only for scripts in res:// scope.

I have project scructure like this

MyNode not viewed in add node menu

It also means that I can't provide global classes through Nuget repository.

This limits CS development functionality.

Perhaps there are other restrictions related to the incompatibility of the Godot and Dotnet project structures.

I think this should be documented.

URL to the documentation page: https://docs.godotengine.org/en/stable/tutorials/scripting/c_sharp/c_sharp_global_classes.html

AThousandShips commented 11 months ago

For NuGet please see these instructions

iRumba commented 11 months ago

For NuGet please see these instructions

You don't understand. I can't use global class from referenced csharp project outside godot project scope (res://)

AThousandShips commented 11 months ago

I do understand... You are not reading what I'm saying, you asked about the use of nuget, I gave you details on that, please read the linked documentation

For the restriction of the file scope I don't know but I suspect this is intentional and should be documented

iRumba commented 11 months ago

I do understand... You are not reading what I'm saying, you asked about the use of nuget, I gave you details on that, please read the linked documentation

For the restriction of the file scope I don't know but I suspect this is intentional and should be documented

Maybe google translator translates wrong, but here:

It also means that I can't provide global classes through Nuget repository.

I meant using global classes from referenced projects, including Nuget references

AThousandShips commented 11 months ago

Did you try importing nuget packages as the documentation instructs?

~For the rest it isn't possible to load scripts (or any resources, i.e. things needing parsing) from outside the res:// scope, and this should be documented more clearly~ My bad got this confused, but global classes outside the project will not be loaded for these purposes

I'd also suggest asking in the other community channels for support, this might be because you haven't configured your project correctly

iRumba commented 11 months ago

Did you try importing nuget packages as the documentation instructs?

Yes, I'm dotnet developer, I know how to import packages in dotnet infrastructure.

For the rest it isn't possible to load scripts (or any resources) from outside the res:// scope, and this should be documented more clearly

But it is possible. I can load resource from user:// scope, for example. Also, maybe I can load resource from global scope (C:/ for windows). Also, I can create class, that extends node in referenced project. But capturing csharp attributes from it is impossible. I don know why. Maybe for reading attributes Godot uses self tools instead of mono. Maybe for global classes (Singletons) Godot needs ResourcePath property, that missed in scripts loaded from referenced projects.

I'd also suggest asking in the other community channels for support

Here? https://forum.godotengine.org/

AThousandShips commented 11 months ago

Yes, that's one of the channels you can ask in 🙂

iRumba commented 11 months ago

Yes, that's one of the channels you can ask in 🙂

But what i should ask there?

I want only to see these constraints in docs

AThousandShips commented 11 months ago

I'd also suggest asking in the other community channels for support, this might be because you haven't configured your project correctly

As I said 🙂, if you are sure that this limitation exists then we can add this

iRumba commented 11 months ago

I'd also suggest asking in the other community channels for support, this might be because you haven't configured your project correctly

As I said 🙂, if you are sure that this limitation exists then we can add this

Yeah, I sure. But maybe are there other constraints with similar cause. You will add information about GlobalClassAttribute today, but tomorrow i will find other attribute with simiar constraint. I think that need analyze of functionality to know cause of this. And after adding it to docs