-
i cannot pass the string to the AddResource method. even I tried to cast it to gd.StringName but still it was unsuccessful. func (w *World) Ready(ctx gd.Context) {
w.Class.Super().SetEnvironment(gd.Environment{})
env.AddResource("world1", "res://world1.tres")
} error: env.AddResource undefined (type "grow.graphics/gd/internal/classdb".Environment has no field or method AddResource) even I've tried to make StringName var but there is no way to add string to it var name gd.StringName
var path gd.Resource |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
It doesn't look like the Godot Environment class has an I regards to func (w *World) Ready() {
var name = w.Temporary.StringName("Go string that will become a StringName")
// do something with name
} Note that for any godot reference types (including string names & classes), the zero value is not valid, ie. it is essentially The The reason why there's this awkward way to create |
Beta Was this translation helpful? Give feedback.
It doesn't look like the Godot Environment class has an
add_resource
method?https://docs.godotengine.org/en/4.2/classes/class_environment.html
I regards to
StringName
, this is a Godot defined reference type, it can be initialised via an availablegd.Lifetime
. The value will be valid for the lifetime of the context.Note that for any godot reference types (including string names & classes), the zero value is not valid, ie. it is essentially
nil
. So passinggd.Environment{}
does not create a new Environment as you may be expecting. Usegd.Create
for this.