Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shorthand for export nodes #17

Open
ghost opened this issue Sep 6, 2022 · 0 comments
Open

Shorthand for export nodes #17

ghost opened this issue Sep 6, 2022 · 0 comments

Comments

@ghost
Copy link

ghost commented Sep 6, 2022

Problem:
When using an exported node in a scene, it is common practice to write two lines: one for the export, and another for loading the node.

For example, if you wanted to use a Camera node from your scene, you would probably do this:

export(NodePath) var camera_path
onready var camera : Camera = get_node(camera_path)

This method wastes an extra line for every exported node! This is not good enough.

Solution:
There is a lesser-known method for using exported nodes in one line. For example, the shorthand for the code written above would be this:

export(NodePath) onready var camera = get_node(camera) as Camera
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants