3 Answers
- Newest
- Most votes
- Most comments
0
Hello @REDACTEDUSER
Yes you can. You can use the Behavior Context to reflect a C++ class into a Lua table. Take a look at this page for more information about the Behavior Context and how you would go about achieving that.
Thanks!
answered 6 years ago
0
Good Question -- Let me find some answers for ya on this topic :)
Apologies for the delays.
answered 6 years ago
0
After much fiddling, I ended up getting a series of classes successfully passed between Lua and C/C++. Doing so required some modification to my core classes (which think I can avoid in the future using wrappers). Additional things that helped me while struggling through this:
- The actual documentation for the behavior context class has a larger code snippet. It essentially has all of the code you linked, but as a single piece, which helped me see exactly where this code had to go.
- Some type of macro is needed (AZ_TYPE_INFO_SPECIALIZE or AZ_RTTI) in order to reflect a class or type. I believe AZ_RTTI has to be in the public part of a class header, and the AZ_TYPE_INFO_SPECIALIZE has to be part of the AZ namespace in order for them to work. If you attempt to reflect without adding these macros, you will get some assertion error.
- NOTE: This also applies to any type that your class returns, including lists/vectors of those classes (i.e. any type not AZ_TYPE_INFO_SPECIALIZE-d in the dev\Code\Framework\AzCore\AzCore\RTTI\TypeInfo.h file)
- \dev\Gems\LmbrCentral\Code\Source\Rendering\MaterialHandle.cpp showed me that methods attached to the reflected classes didn't need to actually be part of the reflected class (MaterialHandle reflection).
- \dev\Code\Framework\AzCore\AzCore\Script\ScriptSystemComponent.cpp Has a full example of reflecting an enum through a class (PlatformID) Thanks! My code is so much easier for me to understand and performs faster as a result of this!
answered 6 years ago
This post is closed: Adding new answers, comments, and votes is disabled.
Relevant content
- How do I update a CloudFormation stack that's failing because of a resource that I manually deleted?AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago