x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AssetManager in cooked build doesnt work.

I'm using AssetManager and AssetRegistry to load content at runtime. It all works in Editor, but fails when using in cooked build. Here Is how I initialize AssetRegistry:

 #include "ActionRPGGame.h"
 #include "Modules/ModuleManager.h"
 #include "AssetRegistryModule.h"
 #include "Engine/AssetManager.h"
 void FActionRPGGameModule::StartupModule()
 {
     FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
     IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
     //AssetRegistryModule.Get().OnFilesLoaded().AddUObject(this, &UARUIAbilityManagerComponent::FinishedLoadinFiles);
     TArray< FString > ContentPaths;
     TArray<FString> RootPaths;
     FPackageName::QueryRootContentPaths(ContentPaths);
     AssetRegistry.ScanPathsSynchronous(ContentPaths);
 
 };
 IMPLEMENT_PRIMARY_GAME_MODULE(FActionRPGGameModule, ActionRPGGame, "ActionRPGGame" );

Then:

 FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>("AssetRegistry");
             IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
 
             TArray<FAssetData> AssetData;
             FARFilter Filter;
             Filter.TagsAndValues.Add("AbilityTagSearch", InAbilityTag.ToString());
             AssetRegistryModule.Get().GetAssets(Filter, AssetData);
             FPrimaryAssetId PrimaryAssetId = FPrimaryAssetId(FPrimaryAssetType("Ability"), AssetData[0].AssetName);
             FPrimaryAssetTypeInfo Info;
             if (Manager->GetPrimaryAssetTypeInfo(PrimaryAssetId.PrimaryAssetType, Info))
             {
                 FStreamableDelegate del = FStreamableDelegate::CreateUObject(this, &UAFAbilityComponent::OnFinishedLoad, InAbilityTag, InInputName, PrimaryAssetId);
 
                 Manager->LoadPrimaryAsset(PrimaryAssetId,
                     TArray<FName>(),
                     del);
             }

Which calls this function, when delegate is called:

 void UAFAbilityComponent::OnFinishedLoad(FGameplayTag InAbilityTag,
     FGameplayTag InInputName, FPrimaryAssetId InPrimaryAssetId)
 {
     if (UAssetManager* Manager = UAssetManager::GetIfValid())
     {
         UObject* loaded = Manager->GetPrimaryAssetObject(InPrimaryAssetId);
         TSubclassOf<UGAAbilityBase> cls = Cast<UClass>(loaded);
         if (cls)
         {
             NativeAddAbility(cls, nullptr, InInputName);
         }
 
         {
             Manager->UnloadPrimaryAsset(InPrimaryAssetId);
         }
     }
 }

In turn it gets to this function:

 const FPrimaryAssetData* UAssetManager::GetNameData(const FPrimaryAssetId& PrimaryAssetId, bool bCheckRedirector) const
 {
     const TSharedRef<FPrimaryAssetTypeData>* FoundType = AssetTypeMap.Find(PrimaryAssetId.PrimaryAssetType);
 
     // Try redirected name
     if (FoundType)
     {
         const FPrimaryAssetData* FoundName = (*FoundType)->AssetMap.Find(PrimaryAssetId.PrimaryAssetName);
         
         if (FoundName)
         {
             return FoundName;
         }
     }

And it turns out that >AssetMap< Is empty for some reason in cooked build.

Any idea how to fix it ?

Product Version: UE Github Master branch
Tags:
more ▼

asked Aug 11 '17 at 03:50 PM in C++ Programming

avatar image

iniside
1.5k 101 96 181

avatar image XIXGAMES Apr 18 '18 at 09:31 AM

I think you need to add the folders/levels you want to load dynamically to be cooked in the project preferences

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Have you ever solved this, iniside? Thanks in advance!

more ▼

answered Nov 19 '18 at 08:51 AM

avatar image

vlad.serbanescu11
14 2 5 6

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question