3 回答
- 最新
- 投票最多
- 评论最多
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!
已回答 6 年前
0
Good Question -- Let me find some answers for ya on this topic :)
Apologies for the delays.
已回答 6 年前
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!
已回答 6 年前
该帖子已关闭:已禁用添加新回答、评论和投票。
相关内容
- AWS 官方已更新 2 年前