When the Play Mode Script is “Use Asset Database” or “Simulate Groups”, the Addressables. If you make changes to a ScriptableObject loaded using LoadAssetAsync, the changes will remain in the Editor.
Of course, this phenomenon does not occur when building on the actual device or when “Use Existing Build” is selected.
Is there a way to make changes to a ScriptableObject without leaving changes in the Editor?
If this problem without Addressable, you can just Instantiate it with Object.Instantiate.
However, when I modify a ScriptableObject named “A” and load a “B” that references “A”, I want it to use the modified “A”.
The behavior on the real machine and “Use Existing Build” works as I expected, but when I do it in the editor, the diff appear every time.
Is there anything I can do?
This is the code I’m running.
IEnumerator Start()
{
Debug.Log("Start");
var baseFontLoader = Addressables.LoadAssetAsync<TMP_FontAsset>("Font/Base");
yield return baseFontLoader;
var baseFont = baseFontLoader.Result;
var language = "japanese"; // In fact, load it from settings.
var additionalFont = "";
if (language == "japanese") additionalFont = "Font/Japanese";
if (language == "chinese") additionalFont = "Font/Chinese";
if (!string.IsNullOrEmpty(additionalFont))
{
var fallbackFontLoader = Addressables.LoadAssetAsync<TMP_FontAsset>(additionalFont);
yield return fallbackFontLoader;
baseFont.fallbackFontAssetTable.Add(fallbackFontLoader.Result);
}
yield return Addressables.InstantiateAsync("TestCanvas"); // Reference to Font/Base
yield return Addressables.InstantiateAsync("TestCanvas2");
Debug.Log("Finish");
}
Maybe try calling Resources.UnloadAsset on your ScriptableObject when exiting play mode. That should discard any change you make.
1 Like
Thank you!
My problem has been solved!