Reading uassets outside of packaged game

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.
1198286a6f.png

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.
3cce88ef63.png

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,

Hi guys. Sorry to bump my own thread. But still haven’t had any luck yet. Anyone done something similar or a better way to achieve what I am trying to do?

Use the game patching system

How would that work? The idea is that I don’t have to update the game. Users should be able to add in files manually under the game directory, and the game would read them.

Isn’t that basically what you would do when you work with the Steam Workshop?
If a user creates something, he would package your game as a DLC and then add the new DLC pak file to the system.
At least that’s how I imagine it to work.

So if you want player to add additional content to your game, you would need to give them your project.
Since you probably don’t want to expose everything to them, you would need to create a modding editor, such as the ones from ARK and Conan.
And that probably results in you needing to ask Epic to add that to their Launcher (probably because of license stuff?)

What you could do is simply loading the SONGs as they are, instead of making them to uasset files.
You should find code for loading and using wav and/or ogg files that are loaded from the HDD.
In fact, my SoundVisualisation plugin does exactly that with OGG files.

It’s not really uptodate at the moment, as I don’t have time to update it to 4.14 and 4.15.

https://github.com/eXifreXi/eXiSoundVis

Thanks for the large response. For some context, this is my game.

The way I want it to work is that the player makes a midi track (using guitar pro, or whatever midi creator they have) to make a track (what spawns the notes) and then use a DAW program to sync it to a YouTube video. Then, the game requires 2 files. The midi track, which thanks to this plug in, is a uasset. And then a material instance that has the texture for the album cover and a bunch of meta data info “Meta-ArtistName-SongName-iDifficulty-iTotalNotes-bUseWAV-sYoutubeID”, so an example would be “Pendragon-Breaking_The_Spell-2-374-0-BItp37gKtAo”. With this the game knows to use the YouTube system, load the YouTube URL, show the album cover, as well as calculate the accuracy of the player at the end. That system works, I have tested it with 2 songs, TenaciousD’s Beelzeboss, and Rick an Morty main theme.

What I imagine the workflow of the player creating their own song is. Pick a YouTube song, create a midi track for it, then sync it using a DAW. Open up their own UE4 engine project, they download the engine just like you and me from epic. Make sure they have the midi plug in. Add the Midi asset to the Content Browser. Rename the Meta Data Material Instance file (I will provide that for now, until I figure a better system). Then, they open in Windows the File Explorer, go to their project and grab the 2 uassets that UE4 made for them.

With those 2 uassets, theoretically, they should be able to place them in the game’s folder and the game should read them, as the function that I made which is on top, is just to look for contents inside of a folder. But it fails to find/read uasset that was not packaged in the original game.

I am currently trying to figure out the Steam workshop, but there is little information on how it works with UE4. I haven’t found a step by step tutorial, so I am struggling quite a bit. A lot of little problems, baffling me out. I guess I will just focus on one problem at a time. For now just uploading stuff to the workshop. Then I will solve subscribing to items, Then I will solve getting the game to read the subbed items.

However, if I can get the game to just simply read out files in the folder, that the players placed manually, that would make my world easier I think, as well as it being more intuitive for the players modding the game.
Could the issue simply be the path that I am using? The variable I am passing to the function is “/Game/MusicShoot/Audio/Songs”. And maybe only that works for the packaged game? I have to use some other function to find the actual full path that the game is installed, and pass that in?

Maybe I am so used to how modding works in other game engines like Source (And Rocksmith), that what I have in mind is not what is gonna work?

Also, your soundVisualisation looks cool. I will look into using it. I actually have my own compiled engine, so if I just download from github and compile it, should be enough right?

Hey @Motanum

I think GitHub - smogworks/ModSkeleton: Go-To Example for Unreal Engine 4 Modding Support could be some help to you. There are two problems with loading assets at runtime in Unreal. 1st, Unreal won’t load any additional pak files automatically. And 2nd, once it does, it doesn’t add any of the assets within the pak file to the in-memory AssetRegistry… so even if the pak is loaded, you won’t be able to access it’s contents.

The ScanForModPlugins() function in ModSkeleton/ModSkeletonRegistry.cpp at master · smogworks/ModSkeleton · GitHub handles both of these cases.

Most of the other code in ModSkeleton is for handling logic (C++ and Blueprints) within the mods, so you may not need it in your case. Once you get the assets added to the AssetRegistry, you can simply search through it to see if there are any new ones available to make use of.

Hi, I need exactly the same functionality, but for another purpose. We are making an MMO and we have a large set of voiceovers. The voiceovers are part of quests, and we dont want to ship all the voiceovers to the clients, as those can be easily extracted and players can listen to end game dialogues. We would like to send to the client only the voice files they need in that particular quest, then cache locally. This mean I need to load .uassets outside of pak at runtime. Did anyone solve this problem, or are the new releases helping compared to this post of 2017?