Saving player altered scene

So, what I’m trying to achieve is similar to what you can do in skyrim and fallout.
If the player enters their home, they can, for example, stack 5 wheels of cheese on a table. When they return to their home from doing quests, those 5 wheels will remain the same way the player left them.

Is there a way of achieving this? I imagine this could be done by saving the scene itself on runtime, but i dont know how.

Any ideas?

The runtime doesn’t have the ability to save scenes as the Editor does, so a different approach would be needed.

To start off, I’m assuming that you’re going to want these changes to persist in the game’s save file, and not just in the current game session, correct? So, before you start looking at this, you’ll need to have a save game system in place. Do you? If you do, the details of how to implement this will differ depending on what kind of save system you have implemented.

If you don’t have one yet (or if you’re using PlayerPrefs so far!), start looking into that first. I recommend either using BinaryFormatter or one of the JSON serializers like LitJSON - with either of those solutions you can just create a class structure for your save data and let the serializer do all the work of putting that class structure into files.

Once you do have a save game system, you’ll then need to figure out a way to represent the changes that a player can make, as data. That might look something like this:

[System.Serializable]
public class RoomData {
public ObjectData[] allObjects;
}

[System.Serializable]
public class ObjectData {
public string prefabName;
public Vector3 pos;
public Quaternion rot;
}

You’ll then look through all of the “changeable” objects (wheels of cheese, etc) in the home, create the ObjectData representing them, and put those into the RoomData’s array. After loading, when the player enters the home, reverse the process.

Looks legit. Just what I was looking for, thanks!