I have a data asset type ( let’s call it OriginalDataAsset ) that I use for storing some criteria. One of the fields in the asset needs to be a string, but I’d like to limit the string to a selection.
The string actually matches up with a string field from a different class of data asset ( lets call it OtherDataAsset ).
I could do something like:
TSoftObjectPtr<OtherDataAsset> Asset;
This would let me filter the list down to the assets - but I just want to store the string from the asset - I don’t want to have to do something like a synchronous load during the gameplay to actually get the field off the asset that I need.
Is there a way either:
1 - Have a dropdown box filtered by TSoftObjectPtr and grab the name off the OtherDataAsset when it’s picked, while authoring the OriginalDataAsset?
or
2 - Create a dynamic dropdown box in the OriginalDataAsset view that pulls the fields from all the instances of the OtherDataAsset and just presents the strings as options?
This will make it so that the FString is a drop down instead of a fully editable text box. That drop down will be populated using the static/member function that you specify with the meta value.
Beyond that your expected to know how to get the list of values that you want.
Alternatively you could use gameplay tags if you’re trying to provide some sort of ID system. Or just leave it as a SoftObjectPtr to the other asset. If you’re not grabbing a string from some collection on that object, there’s really no reason you should store the name of the object instead of a reference to the object directly.
I think the dropdown will work for now - I am worried that this prevents these items from staying in sync. If someone changes the ID on the ‘OtherDataAsset’, then the ‘OriginalDataAsset’ won’t update.
I am curious about your other option - I could use FGameplayTag’s - the issue I have is that I can’t do a load of the ‘OtherDataAsset’ during game-time, due to some other limitations. I don’t need to grab a string from a collection such as a TMap or TArray on the ‘OtherDataAsset’ - but I do need a string ( or a gameplay tag ) from the asset.
Is there some way of grabbing that from the asset, even if I just have a SoftObjectPtr to the asset, without actually loading the asset?
Depending on the data there is. You can set up some data to be included with the asset meta data and you can get that from the AssetRegistry. There some other markup for it but I don’t have any examples on hand.
Right but the point of the gameplay tag would be that you don’t get it from the other asset both assets just reference the same one.
You’ve never really explained what you’re trying to do or what this string is. Overall it’s the sort of thing that you might want to try to avoid. Maybe what you really need is a third asset that your two assets reference that has the shared data. Then you’re just directly referencing the third asset and not doing any of this string nonsense.