Add static methods to C# classes #6744
WhistleWiz
started this conversation in
Scripting
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, most classes in C# only have instance methods available to them.
This goes against most C# built-in types (e.g.
System
namespace), which use static methods for many operations (Godot'sVector3
uses instance methoda.Dot(b);
whileSystem.Numerics
uses static methodVector3.Dot(a, b);
).From my understanding, this is so the GDScript matches 1:1 with C# as closely as possible. My proposal is to be able to use both versions. Static methods make for much cleaner code, and would follow built-in types more closely for C# developers. Certain methods use confusing parameter order too, like
CubicInterpolate
which almost feels like it follows a random order.Implementing this change wouldn't break anything that already exists, but would be a tedious endeavor. There are 3 ways of doing it:
The first would create a lot of duplicate code which doesn't help with future maintenance, while 2 and 3 are basically wrappers which would require minimal change.
Unfortunately I am new user of Godot so I'm not very familiar with the GDScript side of things, so I do not know if there are more challenges to these implementations. I believe #4164 adresses similar issues, but not exactly the same.
Beta Was this translation helpful? Give feedback.
All reactions