diff --git a/Engine/source/T3D/assets/ShapeAsset.cpp b/Engine/source/T3D/assets/ShapeAsset.cpp index d91f70241..5715cdff4 100644 --- a/Engine/source/T3D/assets/ShapeAsset.cpp +++ b/Engine/source/T3D/assets/ShapeAsset.cpp @@ -626,6 +626,32 @@ void ShapeAsset::onTamlPostWrite(void) mNormalImposterFileName = expandAssetFilePath(mNormalImposterFileName); } +void ShapeAsset::onTamlCustomWrite(TamlCustomNodes& customNodes) +{ + // Debug Profiling. + PROFILE_SCOPE(ShapeAsset_OnTamlCustomWrite); + + // Call parent. + Parent::onTamlCustomWrite(customNodes); + + if (!mShape) + return; + + TamlCustomNode* materialsData = customNodes.addNode(StringTable->insert("Materials")); + U32 matCount = mShape->materialList->size(); + Vector& mat_names = const_cast&>(mShape->materialList->getMaterialNameList()); + for (U32 i=0; i < mat_names.size(); i++) + { + StringTableEntry matAssetId = MaterialAsset::getAssetIdByMaterialName(StringTable->insert(mat_names[i].c_str())); + if (matAssetId != StringTable->EmptyString()) + { + String fieldName = String::ToString("materialSlot%d", i); + String fieldData = String::ToString("%s%s", ASSET_ID_FIELD_PREFIX, matAssetId); + materialsData->addField(fieldName.c_str(), matAssetId); + } + } +} + #ifdef TORQUE_TOOLS const char* ShapeAsset::generateCachedPreviewImage(S32 resolution, String overrideMaterial) { diff --git a/Engine/source/T3D/assets/ShapeAsset.h b/Engine/source/T3D/assets/ShapeAsset.h index c2345bf4e..a403b8771 100644 --- a/Engine/source/T3D/assets/ShapeAsset.h +++ b/Engine/source/T3D/assets/ShapeAsset.h @@ -158,6 +158,7 @@ protected: /// Taml callbacks. void onTamlPreWrite(void) override; void onTamlPostWrite(void) override; + void onTamlCustomWrite(TamlCustomNodes& customNodes) override; protected: static bool setShapeFile(void* obj, StringTableEntry index, StringTableEntry data) { static_cast(obj)->setShapeFile(data); return false; }