Resources.unload on scriptable object resets it's prefab references
i'm currently working with a lot of scriptable objects.
one of the features i added for debugging the scriptable objects is unloading all the scriptable objects when the editor window closes.
this allows me to see if my serialization is correct, (hence i dont have to restart unity in order to check if something is 'missing' or reset.)
so far it worked fine with everything (scriptable object's only contained some strings, or other scriptable objects)
The problem: my latest scriptable object contains some public gameobjects(prefabs). everything seems to work fine (recompile / restart unity) however, when unloadresources is called, the references to the prefabs dissapear.
code used to unload
//unload resources
foreach (var m in ModulesEditor)
{
foreach (var f in m.Module.ModuleFeatures)
{
string featpath = AssetDatabase.GetAssetPath(f);
if (featpath.Length != 0)
{
//f is a 'feature', (scriptable object) containing the datamembers
Resources.UnloadAsset(f);
}
}
string modpath = AssetDatabase.GetAssetPath(m.Module);
if (modpath.Length != 0)
{
//m.Module is a scriptable object that contains a list of features (scriptable objects)
Resources.UnloadAsset(m.Module);
}
}
ModulesEditor.Clear();
AssetDatabase.Refresh();
Your answer
Follow this Question
Related Questions
Create Prefabs for Sprites 0 Answers
Is there an easy way to see which GameObjects Prefabs belong to in the editor? 1 Answer
Unity resetting prefab name when saved 1 Answer
because my game does not access my Scriptable Object 0 Answers
Making Node editor but having problem with passing through non static data to static method 0 Answers