-
Notifications
You must be signed in to change notification settings - Fork 86
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
@Node macro #659
base: main
Are you sure you want to change the base?
@Node macro #659
Conversation
We should get it documented. I believe the docs might still point to the original version that might have used property wrappers and was very flaky. The one that came before SceneTree |
Is it worth deprecating or even removing BindNode? |
I think we should deprecate BindNode, it relies on some runtime reflection, which turns out breaks on some platforms as the reflection produces different (and non-deterministic) output. |
Just to confirm: old code using SceneTree will continue to work right? (I do not use it myself, but I rather not break people's code). |
I don't love the name or ergonomics of the @SceneTree macro.
The
path:
label for the argument is visual noise.Requiring the variable type to be optional or implicitly unwrapped also doesn't quite make sense - we may as well support it being non-optional. For non optional variables we'll get a runtime error if the node is missing, which is also true for implicitly unwrapped vars.
This PR introduces a
@Node
macro. It uses the same macro implementation as @SceneTree, but tweaks the interface to be:The scene tree macro implementation has been tweaked to support non-optional type definitions, rather than complaining about them. It does still support implicitly unwrapped types, for backwards compatibility with @SceneTree, which remains unchanged.