question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AdjustSettings ScriptableObject is not saved after settings change

See original GitHub issue

Using v4.23.1. The new AdjustSettings ScriptableObject is not written to disk after toggling anything on it.

Unity keeps the object in memory and the “Toggle …” menu options change values (e.g. isiOS14ProcessingEnabled) on the memory instance but this is not actually saved until you save the current scene or project.

Even worse the “Check …” menu options will report the unsaved value from memory.

This is at least confusing (because source control will not pick the change up until saved) or even dangerous (Unity crashes: the change will be lost).

You should not keep an Instance of the object in memory at all, imho. Load it the moment you want to read or change a value. Then save it if there were changes and unload the object.

So:

var instance = (AdjustSettings)AssetDatabase.LoadAssetAtPath("Assets/Adjust/Editor/AdjustSettings.asset", typeof(AdjustSettings));
// ... read or write value here

// if a value was changed:
EditorUtility.SetDirty(instance);
AssetDatabase.SaveAssets();

For now the workaround is to manually save the project (or scene) after changing the value.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dri-richardcommented, Sep 29, 2020

Can the file be saved to a relative location? Like other projects (and like Adjust itself does) we put 3rd party assets in a separate folder. The current implementation assumes the SDK has been put in the root of Assets.

0reactions
uercegcommented, Oct 5, 2020

Gotcha. I mean, not really sure at this moment what to do about it. It’s hard sometimes to make quick’n’easy and yet solution which can cover all the edge use cases. I guess ideal way would be to allow users to somehow define folder in which they want to see asset being created / loaded, but maybe this can be something to consider for our next major SDK update.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug - When a scriptable object is changed through ...
Outside of the editor, ScriptableObject changes can never be saved back to disk at all, so there's no reason for non-UnityEditor code to...
Read more >
Scriptable Objects Not Saving Data As Expected? : r/Unity2D
I have my settings and inventory setup within SOs, they remember any changes made while I have unity running, but the moment I...
Read more >
How to save a ScriptableObject at runtime after changing ...
1 Answer. You need to introduce Serialization. Save the files on disk before exiting the game (or at "save points") and load it...
Read more >
ScriptableObject
A ScriptableObject is a data container that you can use to save large amounts of data, independent of class instances. One of the...
Read more >
Be CAREFUL with Scriptable Objects! - YouTube
If you try saving data in a Scriptable Object you're going to have some very confusing issues when you make your final build....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found