Open BytesOfPiDev opened 2 years ago
@lsemp3d @carlitosan @onecent1101 This is related to ScriptCanvas needing both SerializeContext reflection in order to save and load variables of that type to the .scriptcanvas file and BehaviorContext reflection to provide bindings to Scripting Languages.
I do think we can add an equivalent RegisterGenericType function to the BehaviorContext, which just goes through the flow of performing OnDemandReflection, as the SetParametersStripped function does. That can trigger calls to the OnDemandReflection template in AzStdOnDemandReflection.inl which is how template types are reflected BehaviorContext
Describe the bug Registering a generic type does not work unless the type is reflected in the behavior context as a member of at least one reflected type.
Sometimes I want to create types for use in ScriptCanvas and its containers(array, set, map). However, unless I have some type that has the generic type as a reflected member, return value or parameter, then it does not show up for use in the appropriate ScriptCanvas container. This forces me to find some way to reflect the generic type inside of something.
Take a look. Here's a hypothetical type that I exclusively want to use in ScriptCanvas. I want to use it in ScriptCanvas' Array container. First, I define the class.
I would expect that I only have to call
to use my type in ScriptCanvas' Array type. However, doing this does nothing that successfully accomplishes that. My type will not show up for use unless I reflect some type containing the generic type as a member, parameter, or return value. In this example, I created
GetEmptyVector()
to use as a workaround.If I reflect this type, I now have the generic type reflected as a return value.
Assets required N/A
Steps to reproduce Steps to reproduce the behavior:
Define a type, e.g.
ReflectionTest
, and reflect it appropriately for use in a ScriptCanvas container (see the example code above)Aside from defining
ReflectionTest
, don't use it anywhere in code except to callReflectionTest::Reflect()
.In ScriptCanvas, notice you can create variables of the type.
Try to create an Array of the type; you'll notice it's not in the list.
Use the type somewhere and use the behavior context to reflect whatever is using it, such as the
GetEmptyVector()
earlier.Now the type shows up.
Expected behavior So long as the types involved are reflected in
AZ::BehaviorContext
, callingAZ::SerializeContext::RegisterGenericType
should be enough to reflect a type for use with ScriptCanvas' containers.Actual behavior Calling
AZ::SerializeContext::RegisterGenericType
will not actually register the type for use in a ScriptCanvas container unless the registered type is used as a return, parameter, or class member inAZ::BehaviorContext
.Screenshots/Video N/A
Found in Branch Development downloaded and installed on 8/3/22.
Desktop/Device (please complete the following information):
Additional context This is related to a different issue I opened, but closed to create a more accurate, detailed ticket. o3de#7474