Are Data Assets Editable During Runtime?

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:


After:

You must save the project if you want those changes saved in the editor.

2 Likes

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.

1 Like

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.

1 Like

Is your amount variable “Instance Editable” in your Data Asset?

1 Like

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:

  1. I discovered the asset type:

  1. Then I realized that I couldn’t directly reference the array values, so I needed to break the parent arrays:

  1. But then I realized that for me to do this in another Blueprint, I needed to cast to this asset. So I created a variable that was a Primary Data Asset and set it to the child class that I needed to cast to:

  1. Now I can edit these things on the fly for temporary calculations/inputs for containers:

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.

2 Likes

Two more things that will be helpful for you to know is that

ou don’t need the cast if the variable is already of the type you use

You can have functions in the data assets themselves usually to do “gets” without needing another blueprints

1 Like