Replies: 2 comments 1 reply
-
Elaborating on this issue, since I was part of the initial discussion: // This is an example C# node template
public partial class _CLASS_ : FoobarNode
{
public void Foobar()
{
// TODO: Implement method
}
} Once you have more than one class named namespace FoobarNodeNamespace // TODO: Remove namespace later
{
public partial class _CLASS_ : FoobarNode
{
public void Foobar()
{
// TODO: Implement method
}
}
} However this effectively means you'd be defining namespaces for every single template. 99% of the time you will not want the new generated file to actually use this namespace though - it makes more sense for it to be in a namespace related to it's domain. |
Beta Was this translation helpful? Give feedback.
-
At the very least I cant think of a reason to not include a snippet in the documents instead of just linking to a page that doesnt help to resolve the issue that is already being acknowledged. |
Beta Was this translation helpful? Give feedback.
-
Describe the project you are working on
A C# project where I would like project-specific script templates
Using Microsoft Visual Studio Community 2022 (64-bit) - Current
Version 17.7.4
Describe the problem or limitation you are having in your project
The templates are .cs files which create build errors.
Within visual studio, doing
right click > remove from project
does not fix build errors as would be expected, except in the case that your template has the class encapsulated in a namespace (not sure why this is the case)The Godot docs page suggests this docs page for help in excluding build files, but for some reason it suggests the
Exclude
keyword when the keyword that works for me isRemove
and also the suggested methods were still not sufficient even when using theRemove
keyword instead.I eventually found that putting
into my .csproj file seems to fix all build errors whilst also providing full template functionality. (
ScriptTemplates
is the name of my template search path which I have set in the Godot project settings)This exact solution is something I could not find reference to anywhere else and would be inconvenient for other C# users to have to discover.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
My suggestion is to have godot automatically add this to the .csproj file depending on what the user has set as their Script Template Search Path within Godot's project settings.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
When the chosen Script Template Search Path in Godot's project settings is changed, search for the exact phrase:
(with
[Script Template Search Path]
being the existing search path) and then replace the old path with the new one. Alternatively, add this to the .csproj file if it is not already there.If this enhancement will not be used often, can it be worked around with a few lines of script?
It could be worked around, though I think there should at least be more accessible information about how to do this in the docs as I had some trouble figuring it out and it would be an inconvenience for any C# developer wanting to use templates.
Is there a reason why this should be core and not an add-on in the asset library?
I think this would pretty clearly be core behaviour if it were to be implemented as this is dealing with a project setting file path
Beta Was this translation helpful? Give feedback.
All reactions