From 794a8c900de74f8afd7d9319d1fa17acee2d4832 Mon Sep 17 00:00:00 2001 From: marauder2k7 Date: Tue, 17 Jun 2025 16:49:07 +0100 Subject: [PATCH] Update ImageAsset.cpp add change notification on intialize asset use this callback to update information about the image on refresh. Remove notification when the asset is removed and when the imagefile changes --- Engine/source/T3D/assets/ImageAsset.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Engine/source/T3D/assets/ImageAsset.cpp b/Engine/source/T3D/assets/ImageAsset.cpp index 99dc97eb9..bc831a2c8 100644 --- a/Engine/source/T3D/assets/ImageAsset.cpp +++ b/Engine/source/T3D/assets/ImageAsset.cpp @@ -213,6 +213,8 @@ bool ImageAsset::onAdd() void ImageAsset::onRemove() { + Torque::FS::RemoveChangeNotification(mImageFile, this, &ImageAsset::_onResourceChanged); + // Call Parent. Parent::onRemove(); } @@ -346,6 +348,9 @@ void ImageAsset::initializeAsset(void) mImageFile = expandAssetFilePath(mImageFile); + if (getOwned()) + Torque::FS::AddChangeNotification(mImageFile, this, &ImageAsset::_onResourceChanged); + populateImage(); } @@ -389,6 +394,8 @@ void ImageAsset::setImageFile(StringTableEntry pImageFile) if (pImageFile == mImageFile) return; + Torque::FS::RemoveChangeNotification(mImageFile, this, &ImageAsset::_onResourceChanged); + if (String(pImageFile).startsWith("#") || String(pImageFile).startsWith("$")) { mImageFile = StringTable->insert(pImageFile);