-
Notifications
You must be signed in to change notification settings - Fork 211
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
Support (or document) downcasting Nodes to scripts #328
Comments
Try looking for |
Thanks for the response. Ok, I saw some stuff about Instance. Once I have
an Instance, how can I get my struct from it? I see a map function, be I
don't really need to map it.
…On Sun, Apr 19, 2020, 22:21 toasteater ***@***.***> wrote:
Try Instance<TestClass>? It is documented, but admittedly hard to find if
you don't know what to look for. There are plans to clean up the top-level
namespace in the next release: #304
<#304>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#328 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFGXF3NLH4HPWRECVJM4D3RNPLUDANCNFSM4MMDJAUA>
.
|
You have to access it using |
Superseded by #330. |
I am guessing this is supported and just not documented (or I'm blind), but I would like a way to "cast" a
Node
to a game script / rust struct. For example:I understand that there is a
cast()
method which sounds great, but doesn't work for me. When I trylet result: TestClass= self.get_node(NodePath::from_str("root/TestClass")).unwrap().cast().unwrap();
, I get the following error:From a cpp/oop perspective, this doesn't make sense because
TestClass
is aNode
which extendsGodotObject
. From a Rust perspective, however, this kinda makes sense becauseTestClass
doesn't actually imelementGodotObject
Ultimately, I understand Rust doesn't have an inheritance tree like most OO languages, but I am not sure how to get the behavior I want. Any help would be appreciated.
The text was updated successfully, but these errors were encountered: