Преглед на файлове

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)