# How to reset a PrimaryDataAsset when testing in the editor?

**URL:** <https://forums.unrealengine.com/t/how-to-reset-a-primarydataasset-when-testing-in-the-editor/450429>\
**Category:** Blueprint\
**Tags:** data, data-asset, testing, reset-to-default, unreal-engine, Blueprint, question\
**Created:** [June 10, 2019, 12:26pm UTC](https://forums.unrealengine.com/t/how-to-reset-a-primarydataasset-when-testing-in-the-editor/450429 "2019-06-10T12:26:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ardenian](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ardenian](https://forums.unrealengine.com/u/Ardenian)\
**Post date:** [June 10, 2019, 12:26pm UTC](https://forums.unrealengine.com/t/how-to-reset-a-primarydataasset-when-testing-in-the-editor/450429/1 "2019-06-10T12:26:52Z")

</div>

After learning that data structures cannot use generalization or inheritance, I searched for an alternate way to create data that allows me to use some kind of generalization. After some time, I stumbled upon the blueprint class _PrimaryDataAsset_ and this appears to be exactly what I am looking for, being very similar to ScriptableObject in Unity.

However, when doing some tests, I noticed that blueprints which inherit from _PrimaryDataAsset_ keep changes even after exiting play mode in the editor. Let’s say there is a boolean variable in my _PrimaryDataAsset_ which I change at runtime, then it will keep that new value when exiting play mode.

While this is actually neat because it allows to keep data, it is also kind of a problem because for instance when testing your stuff, you do not want to have changes from your tests remain after exiting testing. Additionally, when creating games with saves, how would you roll back a _PrimaryDataAsset_, let’s say if you saved your quests flags there and the player reloads a save file from before, when some flags weren’t set.

Is there an easy way to solve this or do I not use _PrimaryDataAssets_ correctly?

---

<div class="post-metadata">

**Author:** ![dorusoftware](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dorusoftware](https://forums.unrealengine.com/u/dorusoftware)\
**Post date:** [July 20, 2022, 8:21am UTC](https://forums.unrealengine.com/t/how-to-reset-a-primarydataasset-when-testing-in-the-editor/450429/2 "2022-07-20T08:21:10Z")

</div>

did you ever figured this out?

---

<div class="post-metadata">

**Author:** ![Ari\_Epic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ari_epic/32/1225266_2.png) [@Ari\_Epic](https://forums.unrealengine.com/u/Ari_Epic)\
**Post date:** [July 20, 2022, 9:35am UTC](https://forums.unrealengine.com/t/how-to-reset-a-primarydataasset-when-testing-in-the-editor/450429/3 "2022-07-20T09:35:55Z")

</div>

DataAssets are never loaded in as instances, you only have access to their in-memory representation of the file itself as a [CDOs](https://forums.unrealengine.com/t/what-is-cdo/310820/3) (Class Default Object). Data Assets should be considered Read Only at runtime and not modified.

You might want to make a normal Blueprint Class just extending UObject instead of a DataAsset and create an instance of it at runtime, then you can change it to your heart’s content without it affecting the source asset itself like is happening in your case.

---

<div class="post-metadata">

**Author:** ![dorusoftware](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dorusoftware](https://forums.unrealengine.com/u/dorusoftware)\
**Post date:** [July 20, 2022, 11:07am UTC](https://forums.unrealengine.com/t/how-to-reset-a-primarydataasset-when-testing-in-the-editor/450429/4 "2022-07-20T11:07:56Z")

</div>

This makes sense. But why it doesn’t reset the data after closing the Play in Editor to simulate how a real game behaves? Anyway, I’m now getting the data from the asset and save it in different variables so the game doesn’t access or change the asset data directly

---

<div class="post-metadata">

**Author:** ![Ari\_Epic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ari_epic/32/1225266_2.png) [@Ari\_Epic](https://forums.unrealengine.com/u/Ari_Epic)\
**Post date:** [July 21, 2022, 6:55am UTC](https://forums.unrealengine.com/t/how-to-reset-a-primarydataasset-when-testing-in-the-editor/450429/5 "2022-07-21T06:55:48Z")

</div>

The editor doesn’t load everything twice when entering PIE so it keeps assets in memory like meshes, textures and CDOs. You’re not supposed to change CDOs, if you do you’re basically changing the in-memory representation of the file which the editor tries its best to not reload unnecessarily. Not reloading them should be fine since CDO’s are not supposed nor expected to be changed during game’s runtime.

---

<div class="post-metadata">

**Author:** ![dorusoftware](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dorusoftware](https://forums.unrealengine.com/u/dorusoftware)\
**Post date:** [July 25, 2022, 7:57am UTC](https://forums.unrealengine.com/t/how-to-reset-a-primarydataasset-when-testing-in-the-editor/450429/6 "2022-07-25T07:57:29Z")

</div>

I’ve switched to loading the data asset and then assign the values to something else inside the game. Now the data assets remain as they are and it is not important if they are loaded in memory or not, I mean, there is no need to reset them back
