فهرست منبع

reload chain execution
for imageassets and materialassets, check any other assets using them, and uppon completion of reloading, kick off the using assets reload as well in serial

AzaezelX 1 سال پیش
والد
کامیت
bfc921da22
2فایلهای تغییر یافته به همراه17 افزوده شده و 0 حذف شده
  1. 9 0
      Engine/source/T3D/assets/ImageAsset.cpp
  2. 8 0
      Engine/source/T3D/assets/MaterialAsset.cpp

+ 9 - 0
Engine/source/T3D/assets/ImageAsset.cpp

@@ -301,6 +301,15 @@ void ImageAsset::initializeAsset()
 void ImageAsset::onAssetRefresh()
 {
    mImagePath = getOwned() ? expandAssetFilePath(mImageFileName) : mImagePath;
+
+   AssetManager::typeAssetDependsOnHash::Iterator assetDependenciesItr = mpOwningAssetManager->getDependedOnAssets()->find(mpAssetDefinition->mAssetId);
+   // Iterate all dependencies.
+   while (assetDependenciesItr != mpOwningAssetManager->getDependedOnAssets()->end() && assetDependenciesItr->key == mpAssetDefinition->mAssetId)
+   {
+      StringTableEntry assetId = assetDependenciesItr->value;
+      AssetBase* dependent = AssetDatabase.acquireAsset<AssetBase>(assetId);
+      dependent->refreshAsset();
+   }
 }
 
 void ImageAsset::_onResourceChanged(const Torque::Path& path)

+ 8 - 0
Engine/source/T3D/assets/MaterialAsset.cpp

@@ -237,6 +237,14 @@ void MaterialAsset::onAssetRefresh()
    }
 
    load();
+   AssetManager::typeAssetDependsOnHash::Iterator assetDependenciesItr = mpOwningAssetManager->getDependedOnAssets()->find(mpAssetDefinition->mAssetId);
+   // Iterate all dependencies.
+   while (assetDependenciesItr != mpOwningAssetManager->getDependedOnAssets()->end() && assetDependenciesItr->key == mpAssetDefinition->mAssetId)
+   {
+      StringTableEntry assetId = assetDependenciesItr->value;
+      AssetBase* dependent = AssetDatabase.acquireAsset<AssetBase>(assetId);
+      dependent->refreshAsset();
+   }
 }
 
 void MaterialAsset::setScriptFile(const char* pScriptFile)