utopia-rise / godot-kotlin-native

Kotlin bindings for Godot Engine
MIT License
290 stars 16 forks source link

Add ResourceLoader.load<T> and Node.getNode<T> extensions #197

Closed raniejade closed 4 years ago

raniejade commented 4 years ago

Instead of writing:

(getNode(NodePath(spriteNodePath)) as Sprite).texture = textureForSprite

You can do:

getNode<Sprite>(pathAsString).texture = textureForSprite
CedNaru commented 4 years ago

I think it's weird to have a global GD.load(String) function in the public singleton but a generic \<T> load(String) as an extension of Resource loader. We should either implement it as a global function or just delete the GDResource directly for consistency.

raniejade commented 4 years ago

@CedNaru I forgot that GD.load exists, I can remove ResourceLoader.load extension. People are probably more familiar with GD.load rather than using ResourceLoader.

CedNaru commented 4 years ago

Okay let's do that.