Hi.
I am making a VR game. We plan to announce early next week. But I will say what it is, because editing the code and folders to hide the game is just too much work, and might interfere with my issue.
Game is called musical Range, you are in a shooting range and you shoot at note panels along the music.
I am trying to implement a system so players can place files into the game’s directory and the game will load those files so they can play custom content. I followed some tutorials, and I made a blueprint function that looks at files inside a specific folder.
//Base Code
//https://answers.unrealengine.com/questions/134539/list-all-maps-in-project-or-directory.html
//
TArray<FString> UMusicalRangeBPFunctionLibrary::GetSongNamesInsideFolder(FString SongPath) {
if (SongPath.IsEmpty())
{
TArray<FString> EmptyArray;
EmptyArray.Add("ERROR");
EmptyArray.Add("Invalid Path");
return EmptyArray;
}
auto ObjectLibrary = UObjectLibrary::CreateLibrary(UObject::StaticClass(), false, true); //UWorld::StaticClass() UObject::StaticClass()
ObjectLibrary->LoadAssetDataFromPath(SongPath); //Path input here "/Game/MusicShoot/Audio/Songs" //Had TEXT() here
TArray<FAssetData> AssetDatas;
ObjectLibrary->GetAssetDataList(AssetDatas);
UE_LOG(LogTemp, Warning, TEXT("Found Songs: %d"), AssetDatas.Num()); //Display ItemsFound
TArray<FString> Names = TArray<FString>();
for (int32 i = 0; i < AssetDatas.Num(); ++i)
{
FAssetData& AssetData = AssetDatas*;
FString name = AssetData.AssetName.ToString();
if (name.Contains("Track-",ESearchCase::CaseSensitive, ESearchDir::FromStart))
{
name.RemoveFromStart("Track-");
Names.Add(name);
}
}
return Names;
}
After I package the game, I upload to Steam, then I install it in my folders. There I create a folders with the same name as the folders that the game have. “Content\MusicShoot\Audio\Songs”
I added my 2 extra songs, which I made by placing in the engine in game. They worked as I can play them. Then I simply grab the uasset, and move it out somewhere else. Then I packaged the game without those 2 songs. So I can later add them as an extra that the player would place.
So in theory, the function library will look at the folder “/Game/MusicShoot/Audio/Songs”, and load those 2 track midi uasset files. But the game will not find those files which are outside of the packaged game “MusicalRange-WindowsNoEditor.pak”.
Then, I tried to remove the “Use Pak File” option in project files, so that the game is packaged with individual uassets.
I then placed the two songs again in the respective folders. This was easier now, and I confirm there is no typo errors, as I can see the other songs there. I highlight the 2 added songs.
However, the game still won’t read those 2 files. When I look at the song selector, those 2 songs are missing.
The game being able to read uassets that are not part of the game would simplify a lot the UCG process for me and for players. Has someone tackled this issue already? What would be the proper way of having the players add custom assets to the game?
Related Answer Hub Question
https://answers.unrealengine.com/questions/561352/how-to-read-uassets-outside-of-packaged-game.html
Thanks,