I have 3 types of Prefab: A, B & C
Whilst designing the levels, in Play Mode, I add and position them within the level.
How do I create a ScriptableObject that holds references to all of the instances of these prefabs and their transforms?
Specifically, whilst in PlayMode, the Scriptable object should dynamically respond to position and rotation changes of the prefabs in PlayMode.
I can't conceive of how to do this, despite this seemingly being a good use of Scriptable Objects.
You could store the information you want in a dedicated class like e.g.
and in your ScriptableObject have a
Then everytime you Instantiate a prefab you also create an according entry in that
instances
.So later in your manager script where you Instantiate the stuff you do e.g.
Now you could either repeatedly or at a certain moment call
Since
InstanceInformation
is a class and thereby a reference-type changing the values here automatically also changes the according entry in theinstances
in the ScriptableObject!So later when you want to load the state you can simply do
Finally in order to be able to store this data persistent you could e.g. use a
BinaryFormatter
like