diff --git a/Engine/source/T3D/assets/MaterialAsset.cpp b/Engine/source/T3D/assets/MaterialAsset.cpp index 77b22cc24..6153cd3e8 100644 --- a/Engine/source/T3D/assets/MaterialAsset.cpp +++ b/Engine/source/T3D/assets/MaterialAsset.cpp @@ -174,11 +174,6 @@ void MaterialAsset::initializeAsset() return; } - if (mMatDefinitionName == StringTable->insert("DetailBlue")) - { - bool asdfsd = true; - } - if (size() != 0 && mScriptPath == StringTable->EmptyString()) { mLoadedState = EmbeddedDefinition; diff --git a/Engine/source/T3D/assets/assetImporter.cpp b/Engine/source/T3D/assets/assetImporter.cpp index de19bc983..865af276f 100644 --- a/Engine/source/T3D/assets/assetImporter.cpp +++ b/Engine/source/T3D/assets/assetImporter.cpp @@ -1727,7 +1727,8 @@ void AssetImporter::processMaterialAsset(AssetImportObject* assetItem) //If there was no existing assetId, then lets see if it already exists in a legacy file, like a materials.cs or materials.tscript //If it does, we'll just make our asset point to that instead of a new file - Material* mat = MATMGR->getMaterialDefinitionByName(assetName); + Material* mat; + Sim::findObject(assetName, mat); if (!mat) mat = MATMGR->getMaterialDefinitionByMapTo(assetName); @@ -2618,6 +2619,8 @@ StringTableEntry AssetImporter::autoImportFile(Torque::Path filePath, String typ else { importAssets(); + + acquireAssets(); } dumpActivityLog(); @@ -2729,10 +2732,6 @@ void AssetImporter::importAssets(AssetImportObject* assetItem) tss->setShapeAssetId(assetId); } } - - //Go ahead and force the asset to load now just to kick it for immediate use - AssetBase* assetDef = AssetDatabase.acquireAsset(assetId); - AssetDatabase.releaseAsset(assetId); } else { @@ -2757,6 +2756,34 @@ void AssetImporter::importAssets(AssetImportObject* assetItem) dumpActivityLog(); } +void AssetImporter::acquireAssets(AssetImportObject* assetItem) +{ + Vector itemList = importingAssets; + if (assetItem != nullptr) + itemList = assetItem->childAssetItems; + + for (U32 i = 0; i < itemList.size(); i++) + { + AssetImportObject* item = itemList[i]; + if (item->importStatus == AssetImportObject::Skipped || + item->importStatus == AssetImportObject::NotProcessed || + item->importStatus == AssetImportObject::Error) + continue; + + //recurse if needed, we want to process child items first for dependency reasons + acquireAssets(item); + + //Go ahead and force the asset to load now just to kick it for immediate use + String assetId = item->moduleName + ":" + item->assetName; + + if (AssetDatabase.isDeclaredAsset(assetId)) + { + AssetBase* assetDef = AssetDatabase.acquireAsset(assetId); + AssetDatabase.releaseAsset(assetId); + } + } +} + // // Type-specific import logic // diff --git a/Engine/source/T3D/assets/assetImporter.h b/Engine/source/T3D/assets/assetImporter.h index 4e2fc53aa..6e77ef965 100644 --- a/Engine/source/T3D/assets/assetImporter.h +++ b/Engine/source/T3D/assets/assetImporter.h @@ -914,6 +914,12 @@ public: /// Torque::Path importShapeAnimationAsset(AssetImportObject* assetItem); + /// + /// Iterates over all the items in the current session and acquires them, which jumpstarts the loading/init'ng process on them, making the available for use immediately + /// @param assetItem, if null, will loop over and recurse the main import asset items, if a specific AssetImportObject is passed in, it will recurse it's children + /// + void acquireAssets(AssetImportObject* assetItem = nullptr); + // /// /// Gets the currently active import configuration diff --git a/Engine/source/T3D/assets/assetImporter_ScriptBinding.h b/Engine/source/T3D/assets/assetImporter_ScriptBinding.h index aa50c82de..a9a94672b 100644 --- a/Engine/source/T3D/assets/assetImporter_ScriptBinding.h +++ b/Engine/source/T3D/assets/assetImporter_ScriptBinding.h @@ -92,7 +92,9 @@ DefineEngineMethod(AssetImporter, resolveAssetItemIssues, void, (AssetImportObje DefineEngineMethod(AssetImporter, importAssets, void, (),, "Runs the actual import action on the items.") { - return object->importAssets(); + object->importAssets(); + + object->acquireAssets(); } DefineEngineMethod(AssetImporter, getAssetItemCount, S32, (),,