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년 전
이 게시물은 마감됨: 새 답변, 댓글 및 투표 추가가 비활성화되었습니다.