Yes, the answer is that RefCounted
can be useful in C#.
I wouldn’t suggest changing Dispose
of GodotObject
. You can think of the engine and the C# memory as somewhat separate. When the object wrapper is disposed in C#, it might still be referenced/be in use by the engine (e.g. think of nodes in the scene-tree). If you want to remove a GodotObject
you should explicitly Free
it, so that the engine object is deleted.
If you want to have the object automatically freed when there is no reference, you should use RefCounted
. But again, just because there is no ‘C# reference’ does not mean that there is no engine reference (e.g., resources attached to nodes). Also note that there can be some delay since the object is only freed when the garbage collector runs (see RefCounted — Godot Engine (stable) documentation in English).
Of course, if you don’t need any engine interop, there is no need to use either. You can and should just use a normal C# object. In this case, the object just resides in the .net managed memory and it is normally garbage collected.
If you are interested it might help to check out the wrapper implementation.