- Home /
The question is answered, right answer was accepted
Storing and Retrieving Data from a ScriptableObject
I've made a custom editor that generates data and stores it into a ScriptableObject asset that is then saved in the project folder. The information saved looks like:
[SerializeField] GameObject obj;
[SerializeField] List<NestedList> list;
I have successfully saved these items into a ScriptableObject. This can be seen using a custom editor that simply exposes the contents of obj
and list
. I can see the Instance ID of obj
, which shows that it has been stored in the asset.
I need to retrieve the data from this ScriptableObject. I have attempted using something similar to:
MyScriptableObject reference = (MyScriptableObject)Selection.activeObject;
This does not get a reference to the ScriptableObject so I can access the obj
and list
fields that have been stored.
Is there a way to do this? SerializedObjects?
Is ScriptableObject even the way to go? The only benefit I see right now vs my own asset file type is the ability to have a custom editor for it.
Thank you.
Answer by Firedan1176 · Jul 15, 2017 at 03:21 AM
I used Resources.Load<MyScriptableObject>(Selection.activeObject.name)
to get my ScriptableObject asset.
However, GameObjects are not being serialized. I will need to make my own interface for that.
Follow this Question
Related Questions
"Unbroken Reference" problem when using a custom Editor to Save/Load a ScriptableObject Asset 0 Answers
Serializing a ScriptableObject without creating an asset for it? 2 Answers
ScriptableObject with Custom Editor resetting data in inspector 1 Answer
CustomEditor for an ScriptableObject asset only works after recompile. 1 Answer
How to save sprite color change on custom inspector ? 0 Answers