Hello,
Is it possible to edit a Data Asset…
…variable during runtime?
If so, how?
Apologies if this was answered already. I’m neck-deep in documentation (Menu/Inventory/Inspection System Pro), and I was hoping to fast-track a concise answer.
Hello,
Is it possible to edit a Data Asset…
…variable during runtime?
If so, how?
Apologies if this was answered already. I’m neck-deep in documentation (Menu/Inventory/Inspection System Pro), and I was hoping to fast-track a concise answer.
Yes you can.
You can modify a DataAssetInstance
as you would any other object in your game.
And this is the setup:
Before:
You must save the project if you want those changes saved in the editor.
Do you mean the player in your game? I don’t think so. It’s unusual for me, though; those are static values that start the game.
Typically, in the projects I’ve worked on, there are two tables: one with default static data (data table or data assets), and then in another table (usually a structure or map) where the changes are saved separately in the savegame. You can then check if a piece of data is saved, and if not, take the data from the static table or data asset.
Thank you for the detailed response, but how do you get a reference to the Data Asset? I tried to cast or get actor of class but that’s not the way to do it.
I’m still learning how these things work, but, in my case, the scenario wouldn’t require a save.
I’m using the assets in a Vendor Menu, so, if you do not have a required vehicle, then the amount of available items in that asset would need to be set to “0”.
On my first screenshot you can see that it is set as a default value. (on the far right) This is possible because Data Asset Instances are available before the game is even started so you can set them as default values.
I know this seems obvious to you, but I REALLY need to see the entire screen to make sure that I’m setting everything up correctly.
This is what’s coming up for me:
Even if you don’t have a savegame, data that can change dynamically is usually transferred from the data asset to the blueprint to a variable, while data that doesn’t change is left in the DataAsset. For example, the initial lifespan.
Although I understand your goal is to save yourself from creating a blueprint with variables that can change.
Okay, so a lot of useful information above, and both helped me get to what I needed. The issue is that I did not create these Data Assets, Moonville did. (The creators of Menu System Pro)
So:
LIFESAVER, @dZh0 and @DomusLudus
It would have taken AGES to figure out on my own.
EDIT:
I did notice that after setting the array value, it PERMANENTLY changed the value in the Data Asset. So, you can see that I set the Amount to “2” upon pressing “U”. When I stopped gameplay and checked the Data Asset, I saw that it had the number two replacing the original value.