Skip to content

How to create a gd.StringName? #8

Answered by Splizard
ardawan asked this question in Q&A
Discussion options

You must be logged in to vote

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 available gd.Lifetime. The value will be valid for the lifetime of the context.

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 nil. So passing gd.Environment{} does not create a new Environment as you may be expecting. Use gd.Create for this.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ardawan
Comment options

@Splizard
Comment options

Answer selected by Splizard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants