- Home /
Pickable items; Editor vs Savegame
Hi there I'm quite new to Unity so pardon me if that might be a stupid question.
I have several pickable items within my level that I would like to place directly within the editor. But I would like those items to be just something like a preset when the level is loaded for the first time. When loading a savegame I would like those items, that where picked up before, to be gone.
Of course I can store the items, that where picked up before, and than remove them during loading time, but that seems like unnecessary work; especially as the number of items within the level might grow.
Is there a more convenient (or a more Unity'ish) way in doing this?
Hope my question is understandable
Regards Marcell
Answer by BlueIceFox · Sep 04, 2017 at 11:26 AM
I'm not sure I follow entirely, what you're trying to do. Scriptable Objects is probably what you're looking for to store the item presets. You could also use json, xml, text files as well but Scriptable Objects are more Unityish... https://docs.unity3d.com/ScriptReference/ScriptableObject.html
Answer by akillingbeck · Sep 04, 2017 at 12:57 PM
Of course I can store the items, that where picked up before, and than remove them during loading time, but that seems like unnecessary work; especially as the number of items within the level might grow.
That is what you need to do. That's what a save system does and it's why you do it at load time.
Using scriptable objects may result in unexpected results unless you know how the serialization process works.
@akillingbeck Ok, I feared that. So if I'm getting that right, if I have a really big level (say many thousands (or even more) of items in the world (it's not what I have but it is possible I guess) and I want to load a savegame (which states that all items have been taken by the player), Unity first needs to load that much data for nothing becaus the player has taken them all? That's really sad I must say. But thanks for the replay anyway.
No, not necessarily. It depends how you create your save system. If you would have that many items there could be some concept of "areas". Then for example, when transitioning areas, you save previous and load the next area.
Partitioning of data is a common practice.
Also, it's not loading it for nothing, it's loading the state it needs to be in (i.e. picked up)
Your answer
Follow this Question
Related Questions
How do you save changes made with custom editor? 3 Answers
Handling change in Class variables with saving ScriptableObject 2 Answers
Is there a way to save Editor configuration without closing Unity? 0 Answers
Combine items in inventory (a la LucasArts) 0 Answers
Is EditorUtility.SetDirty restricted to prefabs or inspected GameObject? 5 Answers