- Home /
Scriptable Object references if not saved in AssetDatabase?
Hello,
Suppose I have a reference to a scriptableObject in my Monobehavior. This scriptableObject was created through the Editor script.
question 1: What happens if I don't save the scriptableObject as an asset into the asset database after I instantiate this scriptableObject?
question 2: Will unity keep the reference to a scriptable Object which was in the Project panel after the game build? Or do I have to manually re-fetch it through "Resources.Load"? What if the Monobehavior is a part of a prefab and is not in the scene?
Answer by Sergio7888 · Dec 02, 2016 at 09:27 PM
1: Any asset file created is added to asset database, if you don't save the ScriptableObject in a file it will not be usable at runtime.
2: If an ScriptableObject reference is set before game build you will have no problem, any thing made after game build will not be in the game, you will need rebuild the game.
Thank you @Sergio7888, I did build tests but still found a weird anomaly about build size, here: http://answers.unity3d.com/questions/1281396/build-size-is-larger-with-null-reference-than-with.html