ソースを参照

Fixing SpawnableScriptAssetRef display in SC (#9237)

* Fixing SpawnableScriptAssetRef display in SC

Signed-off-by: Mikhail Naumov <[email protected]>

* undid the change with only showing children as it hides the variable name in Component Inspector of Script Canvas, making multiple variables undistinguishable.

Signed-off-by: Mikhail Naumov <[email protected]>
Mikhail Naumov 3 年 前
コミット
62bef19b6f

+ 7 - 4
Code/Framework/AzFramework/AzFramework/Spawnable/Script/SpawnableScriptAssetRef.cpp

@@ -21,6 +21,7 @@ namespace AzFramework::Scripts
         {
             serializeContext
                 ->Class<SpawnableScriptAssetRef>()
+                ->Version(0)
                 ->Field("asset", &SpawnableScriptAssetRef::m_asset);
 
             serializeContext->RegisterGenericType<AZStd::vector<SpawnableScriptAssetRef>>();
@@ -31,6 +32,8 @@ namespace AzFramework::Scripts
             {
                 editContext
                     ->Class<SpawnableScriptAssetRef>("SpawnableScriptAssetRef", "A wrapper around spawnable asset to be used as a variable in Script Canvas.")
+                    ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
+                    ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
                     // m_asset
                     ->DataElement(AZ::Edit::UIHandlers::Default, &SpawnableScriptAssetRef::m_asset, "asset", "")
                     ->Attribute(AZ::Edit::Attributes::ShowProductAssetFileName, false)
@@ -42,13 +45,13 @@ namespace AzFramework::Scripts
 
         if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
         {
-            behaviorContext
-                ->Class<SpawnableScriptAssetRef>("SpawnableScriptAssetRef")
-                ->Constructor()
+            behaviorContext->Class<SpawnableScriptAssetRef>("SpawnableScriptAssetRef")
                 ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
                 ->Attribute(AZ::Script::Attributes::Category, "Prefab/Spawning")
                 ->Attribute(AZ::Script::Attributes::Module, "prefabs")
-                ->Property("asset", BehaviorValueProperty(&SpawnableScriptAssetRef::m_asset));
+                ->Constructor()
+                ->Method("GetAsset", &SpawnableScriptAssetRef::GetAsset)
+                ->Method("SetAsset", &SpawnableScriptAssetRef::SetAsset);
         }
     }