Blueprint Data Assets; Asset Registry Not Runtime and Saving a Reference to a Data Asset

Blueprint Only
Trying to figure out how to save a reference to a Data Asset in a SaveGame Slot

I am getting Data Assets by Class to get all the Character Data Assets on Disk (Defaults, DLC, Mods etc.)

Asset Data Breaks into this:
image
It says Struct is Transient and not to be serialized for save game, so if I cannot use the struct directly as a savegame variable, how do I use the variables given when breaking AssetData Struct to get the AssetData back? If you try Make AssetData
image
there is no way to do so, and was trying to figure out how to load a specific Data Asset?
came across this node


but do not know how to use the Object Path? Can it be created using strings and the break of AssetData Struct? Then I could copy the values individually to a new struct in a savegame, to have a reference to the asset in the save, and then using that info, load the asset

Also, Docs state Asset Registry is Editor Only. So, even though this works in “Standalone Game” it still may not work when packaged? (I’d rather not attempt packaging at this time to test and find out)

You can convert AssetData to SoftObjectPath and back.

image

SoftObjectPath can be use in GetAssetByObjectPath or converted to SoftObjectReference, which can be loaded either through LoadAsset.

You can use SoftObjectReference in the save file directly to do LoadAsset later.

P.S. Definitely worth checking if Asset Registry works in the builded project. I for some reason always thought it did work…

Amazing, can’t believe i didn’t come across this! Thank you!

So, with a soft object reference, getting the Asset Data Struct and creating a soft object reference, I want to save it in a map where it is the key, but insteadof a basic object soft reference, I want to limit it to a CaMTDA_Character Soft Object Reference

I just want to confirm that I would be required to actually load the asset to then cast to the appropriate class and the create another Soft Object Reference from the Loaded Casted Object Reference?

Is there a better way to do this? Besides changing the Map Key to just a base Object Soft Reference?

Although I don’t really like the method below, it works: you need to load asset, then cast it, and then receive a soft reference of the required type.

Below? Are you referring to the Load asset → Cast to X → Get Soft Object Reference of X?

I don’t really like it either, is there something else I am unaware of that I SHOULD be doing?

I was going to switch the map key to a base Object Reference, but figured it would be best (as the Map is SPECIFICALLY for THIS CLASS) to have soft reference to the actual object class.

The map is used to store MetaData for an object, a String-String Map variable (String-Struct_String-StringMap)

So, I need to be able at runtime, find the object in the map using its Soft Object Reference, and I am wondering how this works if the Soft Object Reference use din Key of Map, is a Bae Object Reference, andsomewhere else in my code, a Soft Object Reference is created from a Loaded Object that is cast or already loaded as the proper Class? If I pass the Soft Object Reference that is the proper class, and then pass that to a find node for the map, but the keys are Soft Object References to the Base Class, will it properly find the object in the map? I know I could test this, but I am just curious if there are hidden elements on the backend that I am unaware of as to why this would be a bad idea?

I’m not completely sure that it will work, but you can try to make a custom node that will turn the path into a soft reference to the desired class.
I made for my plugin a node that returns a soft reference to an actor of the specified class located on the level.

This is what it looks like under the hood:

void UOGNode_LiteralActor::ExpandNode(FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph)
{
	if (!GetOutActorPin())
	{
		BreakAllNodeLinks();
		return;
	}

	UK2Node_CallFunction* ToSoftObjectReferenceNode = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(this);
	ToSoftObjectReferenceNode->FunctionReference.SetExternalMember(GET_FUNCTION_NAME_CHECKED(UKismetSystemLibrary, Conv_SoftObjPathToSoftObjRef), UKismetSystemLibrary::StaticClass());
	ToSoftObjectReferenceNode->AllocateDefaultPins();
	ToSoftObjectReferenceNode->GetReturnValuePin()->PinType.PinSubCategoryObject = CachedActorClass; // without this the compiler will give an error due to different pin types
	CompilerContext.MovePinLinksToIntermediate(*GetOutActorPin(), *ToSoftObjectReferenceNode->GetReturnValuePin());


	UK2Node_CallFunction* MakeSoftObjectPathNode = CompilerContext.SpawnIntermediateNode<UK2Node_CallFunction>(this);
	MakeSoftObjectPathNode->FunctionReference.SetExternalMember(GET_FUNCTION_NAME_CHECKED(UKismetSystemLibrary, MakeSoftObjectPath), UKismetSystemLibrary::StaticClass());
	MakeSoftObjectPathNode->AllocateDefaultPins();
	MakeSoftObjectPathNode->FindPin(FName("PathString"), EGPD_Input)->DefaultValue = TargetActor.ToString();
	MakeSoftObjectPathNode->GetReturnValuePin()->MakeLinkTo(ToSoftObjectReferenceNode->FindPin(FName("SoftObjectPath"), EGPD_Input));
	
	BreakAllNodeLinks();
}

You can see that the main action is performed by ToSoftObjectReferenceNode, and any reference class can be specified in it.
The standard ToSoftObjectReference node essentially calls the same C++ code, but the returned reference type remains object.
If you wrap it in a custom node (as in my example), everything should work.

This would be great, but i need to keep project Blueprint Only :frowning:

You can make a plugin and then package it. After packaging, you won’t need to use C++ to work with the project that contains this plugin.

P.S. I found that you can call GetFullName from AssetData, and it will contain the path to the asset class (if the asset is a DataAsset, it will contain the path to its PrimaryDataAsset).
Based on this information, you can create a generic “ToSoftObjectReference(AssetData)” node (or something like that) with a dynamically changing output type (class) reference pin.
P.P.S. It’s weird that Epic didn’t make it themselves…

Staying away from Plugins if at all possible, trying o keep everything pure and blueprint only to make upgrading as easy as possible (I upgrade often, and I am a solo dev working on a massive project that will take a lot of time)

This made me realize I could possibly do this


Was trying to figure out how to construct the string, as the Epic site will not load the page where I thought I might find the info i needed…the soft object path breaks into a single string

AsetData Struct Breaks into this
image

and trying to figure out proper syntax for joining values to create a path?

P.S> I tried playing with this idea, but realized it is still going to output a base soft object path, the only way I could get a CaMTDA_Character_Base Soft Object path was to load it, cast it and get new soft object path - I think I will proceed with just changing the map to a base soft object path, hopefully I dn’t find out down the road I need to end up changing a lot of code

Why do you think plugins can negatively affect updates?

On the contrary, I adhere to the method of creating universal and independent (if possible) from each other plugin blocks.

Or the method I described above :slight_smile:
I don’t understand at all why you don’t want to use C++.

  1. I do not know C++, I do not have the time to mess with it as I have waaay too many other things to do being solo
  2. I do not have to compile or mess with Visual Studi
  3. Updates are easier, I just update and good to go
  4. I have had past experience losing an entire project because something happened when I was trying to do a C++ project when compiling or something, IDK, long time ago and forgot

I get why programmers are so adamant about using C++, but I think they forget what its like before they new code

Even though I could have a seperate C++ project just to make that one node a plugin (really, it would be part of my Subsytem and the subsystem itsel would be the plugin)

I am building prototype solo and have 0$ money, and when make money on Prototype, I should be able to make money to hire a good programmer to convert to C++, make the system a plugin, make a plugin for editor for Modders to be able to make content etc.

I am trying to do the best code architecture I can with blueprints to make going to C++ much much easier and quicker.

I do not see in any point in the future for prototype where i would have to have C++

In this case, I do not believe it will matter 0 if that variable is just a base Object Soft Reference

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.