3 réponses
- Le plus récent
- Le plus de votes
- La plupart des commentaires
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!
répondu il y a 6 ans
0
Good Question -- Let me find some answers for ya on this topic :)
Apologies for the delays.
répondu il y a 6 ans
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!
répondu il y a 6 ans
Cette publication est fermée : l'ajout de nouvelles réponses, commentaires et votes est désactivé.
Contenus pertinents
- demandé il y a un an
- demandé il y a 7 mois
- demandé il y a un an
- AWS OFFICIELA mis à jour il y a 2 ans