-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@hmrrrrr thanks for bringing this up, this is an interesting one. So technically speaking, with GDExtension the virtual methods documented for base object instances work differently than with other engine classes. So if you want to override virtual methods on a node, there is an Interface type defined that documents what can be overridden. As for the base For Go doesn't have constructors, instead a common pattern would be to define a Are you hoping to initialise things on the Go side when you call |
Beta Was this translation helpful? Give feedback.
-
@hmrrrrr thanks for your feedback, I've added the following to All exported fields and methods will be exposed to The Engine, so
take caution when embedding types, as their fields and methods
will be promoted. They will be exported as snake_case by default,
for fields, the exported name can be adjusted with the 'gd' tag.
This function accepts a variable number of additional arguments,
they may either be func, map[string]any (where each any is a func),
or map[string]int, these arguments can be used to register static
methods, rename existing methods, or to define constants respectively.
As a special case, if a function is passed which name begins with 'New',
accepts no arguments and returns T, then it will be registered as the
constructor for the class when it is instantiated from within The Engine. You can now register a constructor, add static functions, and rename methods. type HelloWorld struct {
classdb.Extension[HelloWorld, Object.Instance]
}
func NewHelloWorld() *HelloWorld {
fmt.Println("NewHelloWorld!")
return &HelloWorld{}
}
func Static() string {
return "static method call"
}
// Arch returns the current GOARCH value.
func (h *HelloWorld) Arch() string { return runtime.GOARCH }
func main() {
classdb.Register[HelloWorld](NewHelloWorld, Static, map[string]any{
"get_arch": (*HelloWorld).Arch,
})
startup.Scene()
} |
Beta Was this translation helpful? Give feedback.
@hmrrrrr thanks for your feedback, I've added the following to
classdb.Register
: